note 101286 added to function.imagecolorallocate
| From: | kbolinoatsdfdotlonestardotorg at osu1 dot php dot net | Date: | Wed, 08 Dec 2010 01:24:31 +0000 |
| Subject: | note 101286 added to function.imagecolorallocate | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-174695@lists.php.net to get a copy of this message | ||
To amend what oni-kun[at]oni-kun[dot]com said, imagecolorallocate returns an RGB hex value (and thus
can be bypassed) only if the image in question is a 32-bit color image (as created by
imagecreatetruecolor). If the image is a palette-based image (as created by imagecreate), then you
must use imagecolorallocate, which in this case returns a palette index number and not an RGB hex
value.
Code example, for a 32-bit color image:
<?php
$im = imagecreatetruecolor(100, 100);
$white = imagecolorallocate($im, 255, 255, 255);
// now $white == 0xFFFFFF
?>
Code example, for a palette-based image:
<?php
$im = imagecreate(100, 100);
$white = imagecolorallocate($im, 255, 255, 255);
// now $white == index of color #FFFFFF in palette
?>
----
Server IP: 192.41.42.26
Probable Submitter: 130.85.237.74
----
Manual Page -- http://www.php.net/manual/en/function.imagecolorallocate.php
Edit -- https://master.php.net/note/edit/101286
Del: integrated -- https://master.php.net/note/delete/101286/integrated
Del: useless -- https://master.php.net/note/delete/101286/useless
Del: bad code -- https://master.php.net/note/delete/101286/bad+code
Del: spam -- https://master.php.net/note/delete/101286/spam
Del: non-english -- https://master.php.net/note/delete/101286/non-english
Del: in docs -- https://master.php.net/note/delete/101286/in+docs
Del: other reasons-- https://master.php.net/note/delete/101286
Reject -- https://master.php.net/note/reject/101286
Search -- https://master.php.net/manage/user-notes.php