note 31691 rejected from function.imagecolorallocate by spic

From: Date: Wed, 30 Apr 2003 14:40:08 +0000
Subject: note 31691 rejected from function.imagecolorallocate by spic
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-47295@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?

« previous php.notes (#47295) next »