On 08/01/2010, at 10:51 AM, David Blanton wrote: > I have been using > > CGContextRef context; > context = CGBitmapContextCreate (m_bitmap.m_array.m_array, > m_bitmap.m_array.m_pixelsx, m_bitmap.m_array.m_pixelsy, 8, > m_bitmap.m_array.m_pixelsx * 4, > colorSpace,kCGImageAlphaNoneSkipFirst|kCGBitmapByteOrder32Host); > CGImageRelease(m_BitmapImage); > CGContextRelease(context); > CGImageRetain(m_BitmapImage); > > Then > > CGContextDrawImage(cellViewContext, r, m_BitmapImage); > > and all is well. > > > Now I use an NSBitMapImageRep and my colors are off > > m_ptrs[0] = (unsigned char*)m_bitmap.m_array; > m_NSBitmapImageRep = [[NSBitmapImageRep alloc] > > initWithBitmapDataPlanes:m_ptrs > pixelsWide:m_bitmap.m_pixelsx > pixelsHigh:m_bitmap.m_pixelsy > bitsPerSample:8 > samplesPerPixel:3 > hasAlpha:NO > isPlanar:NO > > colorSpaceName:NSCalibratedRGBColorSpace > > bitmapFormat:NSAlphaNonpremultipliedBitmapFormat|kCGBitmapByteOrder32Host > > bytesPerRow:(4*m_bitmap.m_pixelsx) > bitsPerPixel:32]; > I am confused by this as m_bitmap.m_array is created identically in both > examples
What is 'colorSpace' in the first code? Presumably it's not equivalent to NSCalibratedRGBColorSpace, which is what you use in the second one. Thus, colours are taken to be in the colour space assigned to the bitmap. If you use the same colour space for both, you should get the same appearance. --Graham _______________________________________________ Cocoa-dev mailing list ([email protected]) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
