Re: ImageColorAllocate() Problem
| From: | Tom Rogers | Date: | Fri, 03 Oct 2003 06:35:34 +0000 |
| Subject: | Re: ImageColorAllocate() Problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-164860@lists.php.net to get a copy of this message | ||
Hi,
Friday, October 3, 2003, 4:23:27 PM, you wrote:
JRB> I am having a bizzare problem with the imagecolorallocate() function. Maybe
JRB> all of you can help me!
JRB> Here is the code:
JRB> $hex1 = "0x".$color{0}.$color{1};
JRB> $hex2 = "0x".$color{2}.$color{3};
JRB> $hex3 = "0x".$color{4}.$color{5};
JRB> $color = ImageColorAllocate($im, $hex1, $hex2, $hex3);
JRB> Simple enough! $color starts off as a hex color code minus the #, and then
JRB> is pulled into each of the 3 alpha values by way for the hex variables. It
JRB> is later outputted in text:
JRB> ImageTTFText ($im, $cursive_size, 0, $text1_x, $text1_y, $color, $font1,
JRB> $cursive_text);
JRB> Problem: The text is always black.
JRB> Something strange: If I just type in a randomly selected color, it works!
JRB> Is there some reason that the values in my variables wouldn't be passing?
JRB> Thanks in advance,
JRB> Jed R. Brubaker
Use hexdec() function
$hex1 = hexdec(substr($color,0,2});
$hex2 = hexdec(substr($color,2,2});
$hex3 = hexdec(substr($color,4,2});
and it just passes normal numbers to ImageColorAllocate($im, $hex1, $hex2, $hex3)
--
regards,
Tom