2011-11-30 16 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); 

它會好的。