NSGraphicsContext's +graphicsContextWithBitmapImageRep: method has a bug wherein it doesn't correctly map the NSBitmapFormat of the NSBitmapImageRep passed into it to a CGBitmapInfo for CGBitmapContext.
This is a custom implementation that does the same thing, but does not have the bug.
There is one bug: This implementation does not support planar data. It would need to be mixed to chunky (the opposite of planar) first, but then it would not affect the NSBitmapImageRep, since it would be a separate buffer (otherwise I would have to set the planar attribute of the BIR to NO
, which is not possible).
On the other hand, given that I see no way to connect a CGBitmapContext with planar data in the first place (otherwise I'd have done that), perhaps the Apple implementation doesn't support it either. So far, I haven't had the need to try.
If you can figure out a way, feel free to submit a patch.
MD5 and SHA1 signatures were created using the md5sum(1) and sha1sum(1) utilities from GNU coreutils.