Color Calibration Problem

Discussion in 'Mac Programming' started by Thethuthinang, Jun 30, 2012.

  1. Thethuthinang, Jun 30, 2012
    Last edited: Jun 30, 2012

    macrumors member

    #1
    I am reading pixels from an image using NSReadPixel. This gives me a color with NSDeviceRGBColorSpace. I read in a small collection of these colors and then recreate the image with the reduced color set using the NSBitmapImageRep method:

    Code:
    initWithBitmapDataPlanes:(unsigned char **)planes
    pixelsWide:(NSInteger)width
    pixelsHigh:(NSInteger)height
    bitsPerSample:(NSInteger)bps
    samplesPerPixel:(NSInteger)spp
    hasAlpha:(BOOL)alpha
    isPlanar:(BOOL)isPlanar
    colorSpaceName:(NSString *)colorSpaceName
    bytesPerRow:(NSInteger)rBytes
    bitsPerPixel:(NSInteger)pBits
    
    To do this, I need to have my image data as unsigned characters. So I use the NSColor method getRed:green:blue:alpha: (then multiply each of the floats by 255 typecasted as unsigned char). I use NSDeviceRGBColorSpace for the colorSpace name in the initWithBitmapPlanes: method.

    The colors in the image that I get as a result are off. How can I fix this problem?

    If I fill bezier paths with the colors I create from the unsigned char bitmaps, then the colors match better (using both colorWithCalibratedRed:green:blue:alpha: and colorWithDeviceRed:green:blue:alpha:)
     

Share This Page