* * Full LGPL License: * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ /** * Image Class * * @package Image_Class * @version 0.1.0 * @author Remco 'MisterGT' Pander * @access public */ class Image_Class { /** * @var resource * @access private */ var $img; /** * @var resource * @access private */ var $new; /** * Creates new Picture from existing file * * @param var $pic * @return void * @access public */ function newfrompng($pic) { if(!function_exists('imagecreatefrompng')) { die('Check if your GD2 Libary is loaded'); } if(!$this->img = imagecreatefrompng($pic)){ die('Het maken van de afbeelding is mislukt.'); } $this->new = TRUE; $this->init_colors(); } function init_colors() { $this->colors['red'] = imagecolorallocate($this->img, 255, 0, 0); //Red $this->colors['green'] = imagecolorallocate($this->img, 0, 255, 0); //Green $this->colors['blue'] = imagecolorallocate($this->img, 0, 0, 225); //Blue $this->colors['black'] = imagecolorallocate($this->img, 0, 0, 0); //Black $this->colors['grey'] = imagecolorallocate($this->img, 141, 141, 141); //Grey $this->colors['orange'] = imagecolorallocate($this->img, 255, 125, 0); //Orange $this->colors['brown'] = imagecolorallocate($this->img, 72, 53, 34); //Brown $this->colors['yellow'] = imagecolorallocate($this->img, 255, 255, 0); //Yellow $this->colors['white'] = imagecolorallocate($this->img, 255, 255, 255); //White } /** * Creates new Picture * * @param var $x, $y * @return void * @access public */ function newblank($x, $y) { if(!function_exists('imagecreatetruecolor')) { die('Check if your GD2 Libary is loaded'); } if(!$this->img = imagecreatetruecolor($x, $y)){ die('Het maken van de afbeelding is mislukt.'); } $this->new = TRUE; $this->init_colors(); return true; } /** * Define custom colors * * @param var $r, $g, $b, $name * @return void * @access public */ function definecolor($r, $g, $b, $name) { if(!$this->new) { die('There is no IMG created!'); } $this->colors[$name] = imagecolorallocate($r, $g, $b); return true; } /** * Send Headers * * @access public */ function headers() { if(!$this->new) { die('There is no IMG created!'); } @header("Content-type: image/png"); //Output to IMG @header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); @header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); //Date created @header("Cache-Control: no-store, no-cache, must-revalidate"); @header("Cache-Control: post-check=0, pre-check=0", false); @header("Pragma: no-cache"); // HTTP/1.0 } /** * Fill * * @access public */ function fill($color, $x, $y) { if(!$this->new) { die('There is no IMG created!'); } if(!@imagefill($this->img, $x, $y, $this->colors[$color])) { die('Error tijdens het vullen van '.$x.' tot '.$y); } } /** * Create line * * @access public */ function line($color, $x1, $y1, $x2, $y2) { if(!$this->new) { die('There is no IMG created!'); } if(!@imageline($this->img, $x1, $y1, $x2, $y2, $this->colors[$color])) { die('Fout opgetreden tijdens het maken van een lijn!'); } } /** * Add Text * * @param var $size, $x, $y, $color, $font, $text, $angle * @return void * @access public */ function text($size, $x, $y, $color, $font, $text, $angle = NULL) { if(!$this->new) { die('There is no IMG created!'); } if($angle == NULL) { $angle = 0; } imagettftext($this->img, $size, $angle, $x, $y, $this->colors[$color], $font, $text); return true; } /** * Print the image * * @param var $fast * @return void * @access public */ function printToScreen($fast = TRUE) { if(!$this->new) { die('There is no IMG created!'); } @imagepng($this->img); if($fast) { @imagedestroy($this->img); } unset($this->img); } } ?>