I'm trying to create paletted PNG image (8-bit per pixel) that uses RGBA palette (32-bit per palette entry) using Cocoa framework*.
I've tried few combinations for [NSBitmapImageRep initWithBitmapDataPlanes:…]
method. It seems to create appropriate bitmap for bitsPerSample:2
bitsPerPixel:8
.
However, when I try to write such bitmap with [NSBitmapImageRep representationUsingType:NSPNGFileType…]
I get:
libpng error: Invalid bit depth for RGBA image
If I try other bit depths, then I get 32-bit per pixel (non-paletted) image.
*) I know I could just use libpng
, but that's not an answer I'm looking for.