|
Posted by Norman Peelman on 09/04/07 15:35
Michael Fesser wrote:
> .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
Thanks Micha, I can't believe what a horrible post I gave... yuck! I was
five minutes to work when I realized how bad it was.
Norm
Navigation:
[Reply to this message]
|