note 38734 deleted from function.imagecolorallocate by didou

From: Date: Mon, 05 Jan 2004 10:16:04 +0000
Subject: note 38734 deleted from function.imagecolorallocate by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-62940@lists.php.net to get a copy of this message
Note Submitter: xeno ---- If you want to fill an image with a "hexadecimal color" use this function: <?php function hextodec($hex){ $hex=split('#', $hex); $hex=end($hex); $dec=array( "r"=>hexdec(substr($hex, 0, 2)), "g"=>hexdec(substr($hex, 2, 2)), "b"=>hexdec(substr($hex, 4, 2)) ); return $dec; } //Use this function: $color=hextodec("#5522ff"); $bgcol=imagecolorallocate($img, $color[r], $color[b], $color[b]); header("Content-type: image/jpeg"); $img=Imagecreate(100, 100); imagefill($img, 1, 1, $bgcol); imagejpeg($img, 'test.jpg', 100); imagedestroy($img); ?>

« previous php.notes (#62940) next »