改变颜色空间和图像 [英] Changing color space on and image

查看:263
本文介绍了改变颜色空间和图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在基于基于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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆