List Info

Thread: note 78399 added to function.imagecolorallocate




note 78399 added to function.imagecolorallocate
user name
2007-10-10 07:30:12
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]$', $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.imagecolorallo
cate.php
Edit        -- https://master
.php.net/note/edit/78399
Del: integrated  -- h
ttps://master.php.net/note/delete/78399/integrated
Del: useless     -- http
s://master.php.net/note/delete/78399/useless
Del: bad code    -- htt
ps://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     -- http
s://master.php.net/note/delete/78399/in+docs
Del: other reasons-- https://mast
er.php.net/note/delete/78399
Reject      -- https://mast
er.php.net/note/reject/78399
Search      -- https://
master.php.net/manage/user-notes.php

-- 
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )