note 31691 added to function.imagecolorallocate
| From: | usk at cybersite dot dk | Date: | Wed, 30 Apr 2003 12:13:38 +0000 |
| Subject: | note 31691 added to function.imagecolorallocate | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-47290@lists.php.net to get a copy of this message | ||
is it me or does the colors get messed up if you call imagecolorallocate() more than once with the
same color ?
I had $text_color = imagecolorallocate ($im,99,99,99); in a function that was called 10 to 20 times
for the same image and it looked like the color was set in a quite random way.
I expected that imagecolorallocate just would return the index of the color if it already was
allocated, but it doesn't look like it does that.
I fixed it with this
$text_color = imagecolorexact ($im,99,99,99);
if ($text_color < 0)
$text_color = imagecolorallocate ($im,99,99,99);
but is there an explanation to why imagecolorallocate doesn't just return the index already
allocated to the rgb value?
--
http://www.php.net/manual/en/function.imagecolorallocate.php
http://master.php.net/manage/user-notes.php?action=edit+31691
http://master.php.net/manage/user-notes.php?action=delete+31691
http://master.php.net/manage/user-notes.php?action=reject+31691