note 63872 deleted from function.imagecolorallocate by danbrown
| From: | danbrown@php.net | Date: | Fri, 24 Apr 2009 12:49:43 +0000 |
| Subject: | note 63872 deleted from function.imagecolorallocate by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-153664@lists.php.net to get a copy of this message | ||
Note Submitter: erik at phpcastle dot com
----
Hi,
During developing a gradient method I discovered that there can only be 255 colors allocated
somehow...
So the first 255 are going ok and after these the colorallocate function returns -1. My work around
for this problem was to put the allocated color in an array and check if this variable exists before
calling imagecolorallocate again.
Did not had this problem again and my gradient scaled well after discovering this :)
This is the piece of code that created a gradient PNG. The code is top down programmed and not put
in a function or class yet.
Because the code is 124 lines of code I've put the script at my website: http://beta.phpcastle.com/snippets/PHP/Image+Gradient
(website still beta :P)
I hope someone can use this addition