note 78399 added to function.imagecolorallocate
| From: | marszysz at gmail dot com | Date: | Wed, 10 Oct 2007 12:30:12 +0000 |
| Subject: | note 78399 added to function.imagecolorallocate | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-131271@lists.php.net to get a copy of this message | ||
hex2color once again: this is the simplest possible method :)
<?php
$htmlcolor = "FF9900";
$color = hexdec ($htmlcolor);
?>
Let's face the truth: for the truecolor images, imagecolorallocate doesn't allocate
anything, but simply makes a hex representation of color, treats it as one large hex number, and
calculates an int value from it.
Oh, it's probably a good idea to validate $htmlcolor first, like:
<?php
if (!eregi('^[0-9a-f]{6}$', $htmlcolor)) die ("bad color");
?>
----
Server IP: 195.136.184.34
Probable Submitter: 83.18.8.30
----
Manual Page -- http://www.php.net/manual/en/function.imagecolorallocate.php
Edit -- https://master.php.net/note/edit/78399
Del: integrated -- https://master.php.net/note/delete/78399/integrated
Del: useless -- https://master.php.net/note/delete/78399/useless
Del: bad code -- https://master.php.net/note/delete/78399/bad+code
Del: spam -- https://master.php.net/note/delete/78399/spam
Del: non-english -- https://master.php.net/note/delete/78399/non-english
Del: in docs -- https://master.php.net/note/delete/78399/in+docs
Del: other reasons-- https://master.php.net/note/delete/78399
Reject -- https://master.php.net/note/reject/78399
Search -- https://master.php.net/manage/user-notes.php