note 16846 added to function.imagecolorallocate
| From: | ivan at php2 dot chek dot com | Date: | Thu, 15 Nov 2001 18:23:53 +0000 |
| Subject: | note 16846 added to function.imagecolorallocate | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-20881@lists.php.net to get a copy of this message | ||
in reply to hunsvotti
This is not a trouble, it's a feature that saves check overhead
when you know what colors to allocate in advance.
you've got a function that does specifically only that (telling
you whether a given color is already present in the palette)
see imageColorExact
so what you want is
function myImageGetColorIndexOrAllocate($im, $red, $green, $blue){
// whith check overhead
$index = imageColorExact($im, $red, $green, $blue);
if($index == -1){
return imageColorAllocate($im, $red, $green, $blue);
}
else return $index;
}
read the manual :)
--
http://www.php.net/manual/en/function.imagecolorallocate.php
http://master.php.net/manage/user-notes.php?action=edit+16846
http://master.php.net/manage/user-notes.php?action=delete+16846
http://master.php.net/manage/user-notes.php?action=reject+16846