Image_GIS
[ class tree: Image_GIS ] [ index: Image_GIS ] [ all elements ]

Source for file GD.php

Documentation is available at GD.php

  1. <?php
  2. //
  3. // +------------------------------------------------------------------------+
  4. // | PEAR :: Image :: GIS :: GD Renderer                                    |
  5. // +------------------------------------------------------------------------+
  6. // | Copyright (c) 2002-2005 Jan Kneschke <jan@kneschke.de> and             |
  7. // |                         Sebastian Bergmann <sb@sebastian-bergmann.de>. |
  8. // +------------------------------------------------------------------------+
  9. // | This source file is subject to version 3.00 of the PHP License,        |
  10. // | that is available at http://www.php.net/license/3_0.txt.               |
  11. // | If you did not receive a copy of the PHP license and are unable to     |
  12. // | obtain it through the world-wide-web, please send a note to            |
  13. // | license@php.net so we can mail you a copy immediately.                 |
  14. // +------------------------------------------------------------------------+
  15. //
  16. // $Id: GD.php 299207 2010-05-10 10:21:58Z clockwerx $
  17. //
  18.  
  19. require_once 'Image/GIS/Renderer.php';
  20.  
  21. /**
  22.  * GD Renderer.
  23.  *
  24.  * @author      Jan Kneschke <jan@kneschke.de>
  25.  * @author      Sebastian Bergmann <sb@sebastian-bergmann.de>
  26.  * @copyright   Copyright &copy; 2002-2005 Jan Kneschke <jan@kneschke.de> and Sebastian Bergmann <sb@sebastian-bergmann.de>
  27.  * @license     http://www.php.net/license/3_0.txt The PHP License, Version 3.0
  28.  * @category    Image
  29.  * @package     Image_GIS
  30.  */
  31.     /**
  32.     * GD Image Palette.
  33.     *
  34.     * @var array $palette 
  35.     */
  36.     var $palette = array();
  37.  
  38.     /**
  39.     * GD Image Ressource.
  40.     *
  41.     * @var ressource $img 
  42.     */
  43.     var $img;
  44.  
  45.     /**
  46.     * Constructor.
  47.     *
  48.     * @param  mixed   $width 
  49.     * @param  integer $sizyY 
  50.     * @param  boolean $debug 
  51.     * @access public
  52.     */
  53.     function Image_GIS_Renderer_GD($width$height$debug{
  54.         if (is_file($width)) {
  55.             $this->img = imagecreatefrompng($width);
  56.             $width     imagesx($this->img);
  57.             $height    imagesy($this->img);
  58.  
  59.             $this->Image_GIS_Renderer($width$height$debug);
  60.         else {
  61.             $this->Image_GIS_Renderer($width$height$debug);
  62.  
  63.             $this->img = imagecreate($this->width$this->height);
  64.             imagecolorallocate($this->img255255255);
  65.         }
  66.     }
  67.  
  68.     /**
  69.     * Draws a line from ($x1, $y1) to ($x2, $y2)
  70.     * using the color rgb($r, $g, $b).
  71.     *
  72.     * @param  float   $x1 
  73.     * @param  float   $y1 
  74.     * @param  float   $x2 
  75.     * @param  float   $y2 
  76.     * @param  float   $r 
  77.     * @param  float   $g 
  78.     * @param  float   $b 
  79.     * @access public
  80.     */
  81.     function drawLine($x1$y1$x2$y2$r$g$b{
  82.         if (!isset($this->palette[$r][$g][$b])) {
  83.             $this->palette[$r][$g][$bimagecolorallocate($this->img$r$g$b);
  84.         }
  85.  
  86.         imageline(
  87.           $this->img,
  88.           $x1,
  89.           $y1,
  90.           $x2,
  91.           $y2,
  92.           $this->palette[$r][$g][$b]
  93.         );
  94.     }
  95.  
  96.     /**
  97.     * Saves the rendered image to a given file.
  98.     *
  99.     * @param  string  $filename 
  100.     * @return boolean 
  101.     * @access public
  102.     */
  103.     function saveImage($filename{
  104.         return imagepng($this->img$filename);
  105.     }
  106.  
  107.     /**
  108.     * Shows the rendered image.
  109.     *
  110.     * @access public
  111.     */
  112.     function showImage({
  113.         header('Content-Type: image/png');
  114.         imagepng($this->img);
  115.     }
  116. }
  117. ?>

Documentation generated on Mon, 11 Mar 2019 15:39:26 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.