image output code is close to the bottom *******
$image_filename = "../images/tsroll_" . $id . ".png"; //dynamic file name $msg = $rollover; class textPNG { var $font = 'fonts/ARIAL.TTF'; //default font. put in full path. var $msg = "undefined"; // default text to display. var $size = 11; var $rot = 0; // rotation in degrees. var $pad = 0; // padding. var $transparent = 1; // transparency set to on. var $red = 0; // white text... var $grn = 0; var $blu = 0; var $bg_red = 255; // on black background. var $bg_grn = 255; var $bg_blu = 255; function draw() { $width = 499; $height = 14; $offset_x = 0; $offset_y = 0; $bounds = array(); $image = ""; //$this->msg = date ("h:i:s"); // determine font height. $bounds = ImageTTFBBox($this->size, $this->rot, $this->font, "W"); if ($this->rot < 0) { $font_height = abs($bounds[7]-$bounds[1]); } else if ($this->rot > 0) { $font_height = abs($bounds[1]-$bounds[7]); } else { $font_height = abs($bounds[7]-$bounds[1]); } // determine bounding box. $bounds = ImageTTFBBox($this->size, $this->rot, $this->font, $this->msg); if ($this->rot < 0) { // $width = abs($bounds[4]-$bounds[0]); // $height = abs($bounds[3]-$bounds[7]); $offset_y = $font_height; $offset_x = 0; } else if ($this->rot > 0) { // $width = abs($bounds[2]-$bounds[6]); // $height = abs($bounds[1]-$bounds[5]); $offset_y = abs($bounds[7]-$bounds[5])+$font_height; $offset_x = abs($bounds[0]-$bounds[6]); } else { // $width = abs($bounds[4]-$bounds[6]); // $height = abs($bounds[7]-$bounds[1]); $offset_y = $font_height;; $offset_x = 0; } $image = imagecreate($width+($this->pad*2)+1,$height+($this->pad*2)+1); $background = ImageColorAllocate($image, $this->bg_red, $this->bg_grn, $this->bg_blu); $foreground = ImageColorAllocate($image, $this->red, $this->grn, $this->blu); if ($this->transparent) ImageColorTransparent($image, $background); ImageInterlace($image, false); // render it. ImageTTFText($image, $this->size, $this->rot, $offset_x+$this->pad, $offset_y+$this->pad, $foreground, $this->font, $this->msg); // output PNG object. imagePNG($image, $image_filename); } } $text = new textPNG; // instantiate new textPNG class. if (isset($msg)) $text->msg = $msg; // text to display if (isset($font)) $text->font = $font; // font to use (include directory if needed). if (isset($size)) $text->size = $size; // size in points if (isset($rot)) $text->rot = $rot; // rotation if (isset($pad)) $text->pad = $pad; // padding in pixels around text. if (isset($tr)) $text->transparent = $tr; // transparency flag (boolean). if (isset($clr)) { // text colour $text->red = hexdec(substr($clr, 0, 2)); $text->grn = hexdec(substr($clr, 2, 2)); $text->blu = hexdec(substr($clr, 4, 2)); } if (isset($bg)) { // background colour $text->bg_red = hexdec(substr($bg, 0, 2)); $text->bg_grn = hexdec(substr($bg, 2, 2)); $text->bg_blu = hexdec(substr($bg, 4, 2)); } $text->draw(); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php