r/macprogramming • u/Littlefinger6226 • Oct 09 '17
Converting NSImage 24-bit BMP to 2-bit?
I'm relatively new to Mac programming but I do have some experience with Android programming. I'm wondering if there's a way to operate on an NSImage (specifically a BMP image with 24-bit color depth) and compress it to a BMP with only 2-bit color depth.
Apple's doc seems to indicate that Core Graphics only supports up to a minimum of 8-bit. If this is impossible to do using Core Graphics, is there some manual manipulation technique that I can use to iterate over pixel values and threshold them, and export it as a 2-bit color depth BMP?
View all comments
Show parent comment
2
u/Littlefinger6226 Oct 10 '17
Thanks, are you saying to use
bitmapDatato make a newNSBitmapImageRepusing the (crazily long) init methodinitWithBitmapDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:hasAlpha:isPlanar:colorSpaceName:bytesPerRow:bitsPerPixel:? That method's the only one that I see can accept abitsPerSampleargument which would allow me to say I want a 2-bit BMP.