Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determining the Colorspace of a UIImage

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).

Thanks in advance.

like image 954
Matt Avatar asked Nov 12 '10 20:11

Matt


1 Answers

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]);

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

like image 182
Dylan Lukes Avatar answered Oct 17 '22 20:10

Dylan Lukes