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:
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
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
Last edited: