note 16846 deleted from function.imagecolorallocate by jimw
| From: | jimw@php.net | Date: | Sat, 08 Dec 2001 19:55:52 +0000 |
| Subject: | note 16846 deleted from function.imagecolorallocate by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-22145@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 :)