确定UIImage的色彩空间 [英] Determining the Colorspace of a UIImage

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

问题描述

我想知道是否有一种简单的方法来获取图像(即,将图像加载到UIImage中)的色彩空间?例如,我有一个TIFF图像,我希望能够确定它是否使用RGB色彩空间.有没有一种简单的方法可以在不处理像素数据的情况下做到这一点?我知道有一些CGColorSpace函数,但是似乎没有一个可以做到,只是创建色彩空间并对其进行操作(还有更多高级功能).

I'm wondering if there's an easy way to get the colorspace of an image (i.e. an image loaded into a UIImage)? For example, I have a TIFF image and I'd like to be able to determine if it uses the RGB colorspace or not. Is there an easy way to do this without manipulating pixel data? I know there's some CGColorSpace functions, but none of them seem to do this, just create colorspaces and manipulate them (and much more advanced functions).

谢谢.

推荐答案

您必须通过CGImage获取色彩空间.您可以使用以下几行功能/属性来做到这一点:

You have to get the color space through CGImage. You can do it with the following line of functions/properties:

@property(nonatomic, readonly) CGImageRef CGImage

CGColorSpaceRef CGImageGetColorSpace (
   CGImageRef image
);

因此,要获取图像的色彩空间,请执行以下操作:

So to get the color space of an image, you'd do:

CGColorSpaceRef colorspace = CGImageGetColorSpace([myUIImage CGImage]);

当然,请确保遵循CG对象的获取/创建/复制规则.

And of course, make sure to follow the get/create/copy rules for CG objects.

这篇关于确定UIImage的色彩空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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