CGImageCreateWithMaskingColors 删除颜色时留下边框
我使用下面的代码使洋红色透明:
UIImage *inputImage = [UIImage imageWithData:UIImageJPEGRepresentation(anchorWithMask, 1.0)];
const float colorMasking[6] = {0.0, 255.0, 0.0, 2.0, 0.0, 255.0};
CGImageRef imageRef = CGImageCreateWithMaskingColors(inputImage.CGImage, colorMasking);
UIImage *image = [UIImage imageWithCGImage:imageRef];
// add an alpha channel to the image.
结果是具有洋红色边框的图像: https ://i.sstatic.net/kWEXH.png。边框在添加 Alpha 通道之前就已存在,因此与此无关。
有可能摆脱这些边界吗?
I'm using the code below to make the color magenta transparent:
UIImage *inputImage = [UIImage imageWithData:UIImageJPEGRepresentation(anchorWithMask, 1.0)];
const float colorMasking[6] = {0.0, 255.0, 0.0, 2.0, 0.0, 255.0};
CGImageRef imageRef = CGImageCreateWithMaskingColors(inputImage.CGImage, colorMasking);
UIImage *image = [UIImage imageWithCGImage:imageRef];
// add an alpha channel to the image.
The result is an image that has magenta borders: https://i.sstatic.net/kWEXH.png. The borders are present before adding the alpha channel, so it's not related to that.
Is it possible to get rid of those borders?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
会没事的。
It will be ok.
问题出在我正在构建的面具上。将抗锯齿设置为关闭解决了该问题。
The problem was in the mask I was building. Setting antialias to off fixed the issue.