Search code examples
objective-ccocoamacoscolorsnsimage

Changing the Color Space of NSImage


Is there a way I can change the color space of an NSimage or NSBitmapImageRep/CGimage or the like. I am open to any way. Preferably the way photoshop does it.


Solution

  • CGImageRef CGImageCreateCopyWithColorSpace (
       CGImageRef image,
       CGColorSpaceRef colorspace
    );
    

    To get a CGColorSpaceRef, you can do things like

    CGColorSpaceRef CGColorSpaceCreateDeviceRGB();
    

    OR see this page for how to create other color spaces.