|
Posted by Nerd Monster on 09/07/07 15:22
"Norman Peelman" <npeelman@cfl.rr.com> wrote in message
news:46dd7b2b$0$15366$4c368faf@roadrunner.com...
> 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
Thanks to both of you for the help! I've been working on a colorpicker
wysiwyg using Flash with remoting to choose the colors and then php to
process the resulting images. I plan to post my source files here and on
sourceforge when I'm done. Thanks again!
[Back to original message]
|