我有一個PHP變量,其中包含有關顏色的信息。例如$text_color = "ff90f3"
。現在我想給這個顏色imagecolorallocate
。該imagecolorallocate
作品那樣:我怎樣才能給imagecolorallocate一個顏色?
imagecolorallocate($im, 0xFF, 0xFF, 0xFF);
所以,我試圖做到以下幾點:
$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);
它不工作。爲什麼?我嘗試它也沒有bin2hex,它也沒有工作。有人可以幫我嗎?
bin2hex函數做什麼? – 2010-06-02 12:25:58
我把bin2hex放在那裏把字符串轉換成應該給imagecolorallocate的十六進制數字。 – Roman 2010-06-02 12:29:49
「string」和「hexadecimal number」有什麼區別?我問的是這個功能的作用,而不是你爲什麼使用它。它至少會返回什麼?在這種情況下,我的意思是 – 2010-06-02 12:34:32