This bug is +graphicsContextWithBitmapImageRep: doesn't properly map bitmap format to Quartz. It was filed on 2006-08-17 at 19:07 PDT.
+[NSGraphicsContext graphicsContextWithBitmapImageRep:] always returns a RGBA context, even when the image rep is ARGB.
Steps to Reproduce:
- Create an NSBitmapImageRep with an RGB color space and a bitmapFormat that contains the NSAlphaFirstBitmapFormat bit and not the NSFloatingPointSamplesBitmapFormat bit.
- Call +[NSGraphicsContext graphicsContextWithBitmapImageRep:] with the image rep created in step 1.
- Set the current graphics context to the graphics context created in step 2.
WYD (draw) IWYG.
The components in each pixel come out of the image rep permuted, since you expect ARGB from the image rep, but the graphics context put RGBA into it instead.
I did not test with the NSFloatingPointSamplesBitmapFormat bit; therefore, I do not know whether the bug exists with it or only without it.
Reinvent the +graphicsContextWithBitmapImageRep: wheel.