note 63872 added to function.imagecolorallocate
| From: | erik at phpcastle dot com | Date: | Sun, 02 Apr 2006 19:45:06 +0000 |
| Subject: | note 63872 added to function.imagecolorallocate | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-107189@lists.php.net to get a copy of this message | ||
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
----
Server IP: 83.137.20.120
Probable Submitter: 84.87.95.210
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.imagecolorallocate.php
Edit -- http://master.php.net/note/edit/63872
Del: integrated -- http://master.php.net/note/delete/63872/integrated
Del: useless -- http://master.php.net/note/delete/63872/useless
Del: bad code -- http://master.php.net/note/delete/63872/bad+code
Del: spam -- http://master.php.net/note/delete/63872/spam
Del: non-english -- http://master.php.net/note/delete/63872/non-english
Del: in docs -- http://master.php.net/note/delete/63872/in+docs
Del: other reasons-- http://master.php.net/note/delete/63872
Reject -- http://master.php.net/note/reject/63872
Search -- http://master.php.net/manage/user-notes.php