0

Is there any way to check an NSImage's color type in OBJC? I wanna know whether the image is GrayScale or RGB. Any suggestions would help, thanks~

1 Answer 1

0

If you can get the image's color space (possibly from its underlying CGImage) you could determine the number of components in it. If its < 3 you have a monochrome image.

However an image could still be monochrome and have a color color space.

2
  • Thank's a lot! I've found the solution following your advice. I can change the NSImage into NSBitmapImageRep, and there's a property called "colorSpaceName" for NSBitmapImageRep. It will return a NSString which indicates the color space type of the image. That's actually what I want! Thanks!
    – LYTTE_LJ
    Sep 17, 2012 at 7:21
  • As long as you know the source of your image will always use a monochrome color space. Personally I wouldn't use the name of the color space since that could change in the future--number of components should be accurate.
    – nielsbot
    Sep 17, 2012 at 17:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.