note 38734 added to function.imagecolorallocate
| From: | xeno at rn2 dot php dot net | Date: | Mon, 05 Jan 2004 09:17:37 +0000 |
| Subject: | note 38734 added to function.imagecolorallocate | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-62938@lists.php.net to get a copy of this message | ||
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);
?>
----
Manual Page -- http://www.php.net/manual/en/function.imagecolorallocate.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+38734
Delete -- http://master.php.net/manage/user-notes.php?action=delete+38734&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+38734&report=yes
Search -- http://master.php.net/manage/user-notes.php