所以我有PNG圖像,我旋轉它,但我得到一個黑色背景..或者,如果我做的顏色代碼OFR白我白拿。我試着這樣做..如何在使用php轉動png圖像後獲得透明背景?
$trans = imagecolorallocatealpha(image, 0, 0, 0, 127);
imagerotate($image, $degree, $trans)
我也試過..
$trans = imagecolorallocatealpha($image, 255, 255, 255, 127);
有人可以幫我嗎?
這裏是我的代碼..如果我改變allocatealpha爲0,0,255,0然後它變藍。但0,0,0,127仍然是黑色。
function rotate($degrees) {
$image = $this->image;
imagealphablending($image, false);
$color = imagecolorallocatealpha($image, 0, 0, 0, 127);
imagefill($this->image, 0, 0, $color);
$rotate = imagerotate($image, $degrees, $color);
imagesavealpha($image, TRUE);
$this->image = $rotate;
是否原代碼使用'image'而不是'$ image'這樣? – MiffTheFox 2010-11-10 20:34:35
是啊,他們原來的代碼使用$圖片 – Chris 2010-11-11 03:56:44