I would like to generate PNG images with 1bits (2 colors) or 2bit (4 colors) depth with the library Libpng.
Does any one know how to do it ? I have tested examples, and they all seem to work with 8bit color depth ?
I know png_set_IHDR but in the example I test, when I change the depth parameter in png_set_IHDR from 8 to 2 or 1, my program draw one pixels of 2 or 4. I think, it's due to the memory allocation created with the png_malloc function.
In the example I try to modify (http://www.lemoda.net/c/write-png/), the png_malloc function allocates all pixels of the image with sizeof uint8_t.
png_malloc (png_ptr, sizeof (uint8_t) * bitmap->width * pixel_size);
Can you tell to me how to allocate 1bit or 2bits pixels ?
Thank's Jo2s