drawttftext(30, 0, 10, 39, $time, 1,'Ni7seg.ttf'); # # Example 2 # require_once('AastraIPPhoneGDImage.class.php'); # $PhoneImageGD = new AastraIPPhoneGDImage(); # $utf8text = "东丝丞丟丸"; # $PhoneImageGD->drawttftext(20, 0, 5, 35, $utf8text, 1,'arialuni.ttf'); # ######################################################################################################## ######################################################################################################## class AastraIPPhoneGDImage { var $_img; var $_white; var $_black; var $_red; var $_green; var $_blue; var $_font; var $_fontpath; var $_color; function AastraIPPhoneGDImage($width=144,$height=40,$color=False) { # create the actual image $this->_color=$color; if($color) { $this->_img=imagecreatetruecolor($width, $height); } else { $this->_img=imagecreate($width, $height); } # define black and white $this->_white = imagecolorallocate($this->_img, 255, 255, 255); $this->_black = imagecolorallocate($this->_img, 0, 0, 0); if($color) { $this->_red = imagecolorallocate($this->_img, 255, 0, 0); $this->_green = imagecolorallocate($this->_img, 0, 255, 0); $this->_blue = imagecolorallocate($this->_img, 0, 0, 255); } # Black and White only so disable anti-aliasing if(!$color) { $this->_black = $this->_black * -1; $this->_white = $this->_white * -1; } # define a default font path $os = strtolower(PHP_OS); if(strpos($os, "win") === false) $this->_fontpath='../fonts'; else $this->_fontpath='C:\Windows\Fonts'; putenv('GDFONTPATH='.$this->_fontpath); } function importFromPng($file,$x,$y) { $image=@imagecreatefrompng($file); imagecopy($this->_img,$image,$x,$y,0,0,imagesx($image),imagesy($image)); } function setFontPath($fontpath) { $this->_fontpath=$fontpath; putenv('GDFONTPATH='.$this->_fontpath); } function drawttftext($size, $angle, $x, $y, $text, $colorIndex, $font) { imagettftext($this->_img, $size, $angle, $x, $y, $this->getColor($colorIndex), $font, $text); } function drawtext($size, $x, $y, $text, $colorIndex) { imagestring($this->_img, $size, $x, $y, $text, $this->getColor($colorIndex)); } function setGDImage($image) { $this->_img=$image; } function getGDImage() { return $this->_img; } function savePNGImage($filename) { imagepng($this->_img,$filename); } function rectangle($x1, $y1, $x2, $y2, $colorIndex, $filled=False) { if($filled) imagefilledrectangle($this->_img, $x1, $y1, $x2, $y2, $this->getColor($colorIndex)); else imagerectangle($this->_img, $x1, $y1, $x2, $y2, $this->getColor($colorIndex)); } function ellipse($cx, $cy, $width, $height, $colorIndex, $filled=False) { if($filled) imagefilledellipse($this->_img, $cx, $cy, $width, $height, $this->getColor($colorIndex)); else imageellipse($this->_img, $cx, $cy, $width, $height, $this->getColor($colorIndex)); } function line($x1, $y1, $x2, $y2, $colorIndex, $dashed=False) { if(!$dashed) imageline($this->_img, $x1, $y1, $x2, $y2, $this->getColor($colorIndex)); else { $style = array($this->_black, $this->_white); imagesetstyle($this->_img, $style); imageline($this->_img, $x1, $y1, $x2, $y2, IMG_COLOR_STYLED); } } function getColor($index) { if ($index == 0) return $this->_white; else if ($index == 1) return $this->_black; else if ($index == 2) return $this->_red; else if ($index == 3) return $this->_green; else if ($index == 4) return $this->_blue; } } ?>