2011-11-30 17 views
4

当我使用下面的代码,以使洋红色透明: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. 

结果是具有红色边框的图像:http://i.imgur.com/4g6lM.png。在添加Alpha通道之前,边框是存在的,所以它与此无关。

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

回答

0

问题出在我正在建造的面具上。将抗锯齿设置为关闭可解决问题。

+0

你能解释一下什么是错的,你是如何解决它的? – Dejell

3
CGContextSetShouldAntialias(UIGraphicsGetCurrentContext(), NO); 

它会好的。