Image_GIS2
[ class tree: Image_GIS2 ] [ index: Image_GIS2 ] [ 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$
  17. //
  18.  
  19. require_once 'Image/GIS2/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_GIS2
  30.  */
  31.     /**
  32.     * GD Image Ressource.
  33.     *
  34.     * @var ressource $image 
  35.     */
  36.     private $image;
  37.  
  38.     /**
  39.     * GD Image Palette.
  40.     *
  41.     * @var array $palette 
  42.     */
  43.     private $palette = array();
  44.  
  45.     /**
  46.     * Constructor.
  47.     *
  48.     * @param  mixed   $width 
  49.     * @param  integer $sizyY 
  50.     * @param  boolean $debug 
  51.     * @access public
  52.     */
  53.     public function __construct($width$height$debug{
  54.         if (is_file($width)) {
  55.             $this->image imagecreatefrompng($width);
  56.  
  57.             $width  imagesx($this->image);
  58.             $height imagesy($this->image);
  59.         else {
  60.             $this->image imagecreate($this->width$this->height);
  61.  
  62.             imagecolorallocate($this->image255255255);
  63.         }
  64.  
  65.         $this->Image_GIS2_Renderer($width$height$debug);
  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.     public function drawLine($x1$y1$x2$y2$r$g$b{
  82.         if (!isset($this->palette[$r][$g][$b])) {
  83.             $this->palette[$r][$g][$bimagecolorallocate($this->image$r$g$b);
  84.         }
  85.  
  86.         imageline(
  87.           $this->image,
  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.     public function saveImage($filename{
  104.         return imagepng($this->image$filename);
  105.     }
  106.  
  107.     /**
  108.     * Shows the rendered image.
  109.     *
  110.     * @access public
  111.     */
  112.     public function showImage({
  113.         header('Content-Type: image/png');
  114.         imagepng($this->image);
  115.     }
  116. }
  117. ?>

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