为什么我用php旋转后无法使png的背景透明?
发布时间:2020-12-13 13:06:49 所属栏目:PHP教程 来源:网络整理
导读:我昨天整天试着试图解决这个问题.我通过imagerotate()旋转图像.我得到一个黑色背景,图像不再覆盖.我已经尝试了一切我无法想到的,使背景透明化.. 这是我目前的代码.. function rotate($degrees) { $image = $this-image; imagealphablending($image,false); $
我昨天整天试着试图解决这个问题.我通过imagerotate()旋转图像.我得到一个黑色背景,图像不再覆盖.我已经尝试了一切我无法想到的,使背景透明化..
这是我目前的代码.. function rotate($degrees) { $image = $this->image; imagealphablending($image,false); $color = imagecolorallocatealpha($image,127); $rotate = imagerotate($image,$degrees,$color); imagecolortransparent($rotate,$color); imagesavealpha($image,true); $this->image = $rotate; } 我真的开始被勾掉了.有人能告诉我一些工作代码吗?请? 我的WAMP服务器和Dreamweaver可能有问题吗?因为我甚至尝试了这个.. http://www.exorithm.com/algorithm/view/rotate_image_alpha,它仍然是黑色或白色背景..
尝试在旋转的图像上设置imagesavealpha().
目前,您在原始图像上运行imagesavealpha(). [例如imagesavealpha($image,true); ] 相反,你想在旋转的图像上运行imagesavealpha(),然后设置$this-> image … try: ... $rotate = imagerotate($image,$color); imagecolortransparent($rotate,$color); imagesavealpha($rotate,true); // <- using $rotate instead of $image $this->image = $rotate; } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |