ios - CGImageCreateWithMaskingColors 删除颜色时离开边框

标签 ios uiimage cgimage

我正在使用下面的代码使洋红色透明:

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.

结果是一张带有洋红色边框的图像:http://i.imgur.com/4g6lM.png .边框在添加 alpha channel 之前就已存在,因此与此无关。

是否有可能摆脱这些边界?

最佳答案

CGContextSetShouldAntialias(UIGraphicsGetCurrentContext(), NO);

会好的。

关于ios - CGImageCreateWithMaskingColors 删除颜色时离开边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8320735/

相关文章:

iphone - 如何在 iphone 中增加和调整 tableview 单元格的大小?

ios - 无法在我的 View Controller 中看到 Collection View

ios - 为什么我不能设置暴露给 JavaScriptCore 的 Swift 字典项?

ios - 如何从 SKSpriteNode 获取图像名称?

ios - 将索引颜色 .png 转换为 RGB 或灰度

ios - 来自肖像 UIImage 的 CGImage

objective-c - 如何在注册点击量后删除或停止 TableView 中的按钮工作

swift - 如何在 dequeueReusablecell 中显示适当的图像?

ios - Tesseract OCR iOS 图片格式

objective-c - 如果 CGImageCreate 的数据提供者使用由应用程序创建的数组,那么对 CGImageCreate 的正确调用会是什么样子?