How can I give a color to imagecolorallocate?
Posted
by Roman
on Stack Overflow
See other posts from Stack Overflow
or by Roman
Published on 2010-06-02T12:24:10Z
Indexed on
2010/06/02
12:33 UTC
Read the original article
Hit count: 145
I have a PHP variable which contains information about color. For example $text_color = "ff90f3"
. Now I want to give this color to imagecolorallocate
. The imagecolorallocate
works like that:
imagecolorallocate($im, 0xFF, 0xFF, 0xFF);
So, I am trying to do the following:
$r_bg = bin2hex("0x".substr($text_color,0,2));
$g_bg = bin2hex("0x".substr($text_color,2,2));
$b_bg = bin2hex("0x".substr($text_color,4,2));
$bg_col = imagecolorallocate($image, $r_bg, $g_bg, $b_bg);
It does not work. Why? I try it also without bin2hex, it also did not work. Can anybody help me with that?
© Stack Overflow or respective owner