2012-11-19 103 views
1

我使用imagefill()來更改背景顏色(如果是image.But),但同時這樣做的其他區域不受影響,將其顏色更改爲黑色。imagefill()將該區域的其餘區域變爲黑色

$image = imagecreatefrompng("sample.png"); 
$background = imagecolorallocate($image, 255, 0,0); 
imagefill($image, 0,0, $background); 
header("content-type: image/png"); 
imagepng($image,"sample.png"); 

這是我的code.Can任何人都可以告訴我這是怎麼發生的?

回答

0

試試這個代碼ref

$color = imagecolorallocate($im, 255, 0, 0); 
imagefill($im, 0, 0, $color);