改变颜色空间和图像

我正在创build一个基于DeviceGray色彩空间的图像掩码。

基本上我想要做的是将各种灰色(黑色)像素变成白色,并保留黑色像素。

所以我希望我的图像与黑白像素一致。

任何想法如何实现,使用CoreGraphics意味着什么?

请不要提供循环中的所有像素运行

像这样一起使用CGImageCreateWithMaskingColorsCGContextSetRGBFillColor

 CGImageRef myMaskedImage; const CGFloat myMaskingColors[6] = { 0, 124, 0, 68, 0, 0 }; myColorMaskedImage = CGImageCreateWithMaskingColors (image, myMaskingColors); CGContextSetRGBFillColor (myContext, 0.6373,0.6373, 0, 1); CGContextFillRect(context, rect); CGContextDrawImage(context, rect, myColorMaskedImage); 

顺便提一下,在CGImageCreateWithMaskingColors讨论中提到了填充颜色。