改变颜色空间和图像 [英] Changing color space on and image
问题描述
我正在基于基于DeviceGray色彩空间的图像创建遮罩。
I'm creating a mask based on DeviceGray color space based image.
基本上我想做的是将各种灰色(黑色旁边)像素变成白色,并保留黑色像素。
What basically I want to do is to change all sorts of gray (beside black) pixels into white and leave black pixels as they are.
所以我希望我的图像由黑白像素组成。
So I want my image to be consisted with black and white pixels.
任何想法如何使用CoreGraphics实现这意味着什么?
Any idea how to achieve that using CoreGraphics means ?
请不要提供在循环中运行的所有像素
Please dont offer running all over the pixels in the loop
推荐答案
像这样使用 CGImageCreateWithMaskingColors
和 CGContextSetRGBFillColor
:
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 讨论。
By the way, the fill color is mentioned at the CGImageCreateWithMaskingColors discussion.
这篇关于改变颜色空间和图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!