Question

Is this extra headers? I want a simple two color (black and white) 8 bit image to be created from a binary array I am getting from another program. Any suggestions?

NS

Was it helpful?

Solution

The 8 bit BMP uses a color table, which has 256 entries (one for each byte value) 4 bytes each (3 for RGB and 1 for alpha or just for alignment). (But: read the comment by user763305.)

Anyway, have a look at the PNG format, it is usually the easiest format for lossless image file interchange. You can choose between 1-bit grayscale (i.e., B&W) and 8-bit grayscale.

OTHER TIPS

Every actual image format that i know will have a header of some type stored in it. Without knowledge of how many rows or columns the image is supposed to have, or what the bytes are supposed to represent, you would have no way to reconstruct the image later.

You can however get pretty close with one of the binary formats of Netpbm. This should be mostly raw bytes with a very simple header prepended to the front.

http://en.wikipedia.org/wiki/Netpbm_format

Look specifically at P4, which has the following header format followed by black and white binary

P4
# filename.pbm
24 7
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top