note 13848 added to function.imagecolorallocate.php
| From: | kyhm at email dot com | Date: | Thu, 05 Jul 2001 23:28:53 +0000 |
| Subject: | note 13848 added to function.imagecolorallocate.php | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-15024@lists.php.net to get a copy of this message | ||
It would seem that with the nifty new TrueColor functions, the behaviour of "first color
allocated becomes the background color" goes away, at least on 4.0.6 with gd 2.0.1.
I imagine this is because gd sets the pixels of a newly-created image to 0 (with memset() or
similar). For indexed colors, the first color allocated will be 0, and set the background color.
For Truecolor images, this is pure black.
As advised above, paint in your background explicitly. I use
imageFilledRectangle($img, 0, 0, $xs, $ys, $col),
which is faster than imageFill(), 136ms rather than 398ms on my system.
http://www.php.net/manual/en/function.imagecolorallocate.php