|
Posted by Michael Fesser on 09/04/07 11:21
..oO(Nerd Monster)
>Thanks Norm! Here's the problem, and you can test these complete examples on
>your own machine to verify.
>The following works correctly:
But it is not correct!
>-----
><?php
>$im = imagecreatetruecolor(100, 100);
>
>$fillcolor = imagecolorallocate($im, 0, 0, 0x00FF00);
As said, the numbers passed to imagecolorallocate() have to be 0..255.
To split a given hex string into its color parts, you could use string
functions or something like this:
function imageColorAllocateHex($im, $color) {
$c = hexdec($color);
return imageColorAllocate($im,
0xFF & $c >> 0x10,
0xFF & $c >> 0x8,
0xFF & $c
);
}
Usage:
$color = imageColorAllocateHex($im, '00FF00');
Micha
Navigation:
[Reply to this message]
|