2

我有一个有点高级的问题,我想在半透明且 png 具有透明区域的 png 图像上进行自定义形状模糊,然后在图像周围画一个笔触(避免 png 图像中的透明区域)。我尝试使用 GPUImage 在图像上制作蓝色,但在图像的非透明部分周围绘制笔画时被阻塞。我尝试使用这种方法(https://stackoverflow.com/a/15010886/4641980)但是笔划是半透明的(因为图像不透明部分是半透明的)。

我需要你的帮助才能完成这项工作。这个例子几乎就是我的意思

http://i.stack.imgur.com/YdITu.png

我花了很多时间寻找和尝试,但到目前为止都是徒劳的,我将非常感谢您的帮助。谢谢你。

4

1 回答 1

0

您可以使用“CAShapeLayer”来剪辑(或遮盖)模糊图像。为此,您需要遮罩(或剪切)形状的 CGPath。

CAShapeLayer *pathLayer = [CAShapeLayer layer];
pathLayer.frame=CGRectMake(-imageView.frame.origin.x, -imageView.frame.origin.y, imageView.frame.size.width, imageView.frame.size.height);
pathLayer.path = yourClippingPath.CGPath;
pathLayer.strokeColor = [[UIColor blackColor] CGColor];
pathLayer.fillColor = [[UIColor clearColor] CGColor];
pathLayer.lineWidth = 6.0;
pathLayer.lineJoin = kCALineJoinBevel;
[imageView.layer addSublayer:pathLayer];
于 2015-06-16T11:29:37.890 回答