所以我有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