如何在保持透明度的同时旋转GD图像库中的图像? [英] How to rotate an image in GD Image Library while keeping transparency?

查看:78
本文介绍了如何在保持透明度的同时旋转GD图像库中的图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的网站制作皮肤预览器;我需要旋转图像的一部分以创建表示形式,以供用户查看.

皮肤是PNG文件,它的所有部分可能都具有透明度,甚至根本没有透明度.

我需要能够旋转此图像,同时保持图像内部的任何透明性为透明,同时还要使扩展边框(旋转之前不是图像的一部分的区域)透明.

我所有的尝试都在图像本身周围留下了黑色边框.

有帮助吗?

解决方案

  1. 切出要旋转的图像
  2. 使用类似 http://www.exorithm.com/algorithm/view的内容来旋转保留alpha /rotate_image_alpha
  3. 使用以下方法重新合并以保留Alpha:

-

imagesetbrush($destimg, $srcimg);
// x, y are the center of target paste location
imageline($destimg, $x, $y, $x, $y, IMG_COLOR_BRUSHED);

I'm making a skin previewer for my site; I need to rotate parts of an image to create a representation of this for my users to see.

The skin is a PNG file, and all parts of it may have transparency or even none at all.

I need to be able to rotate this image while keeping any transparency inside the image transparent, while also having the extended borders (You know, the area that wasn't part of the image before it was rotated) transparent.

All of my attempts have left a black border around the image itself.

Any help?

解决方案

  1. Cut out the piece of the image you want to rotate
  2. Rotate preserving alpha using something like this http://www.exorithm.com/algorithm/view/rotate_image_alpha
  3. Merge back in preserving alpha using the following:

-

imagesetbrush($destimg, $srcimg);
// x, y are the center of target paste location
imageline($destimg, $x, $y, $x, $y, IMG_COLOR_BRUSHED);

这篇关于如何在保持透明度的同时旋转GD图像库中的图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆