user2148707
user2148707

Reputation: 93

why 1x1 size 8bit bmp is 1082 bytes 24 bit is just 58 bytes?

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

Upvotes: 1

Views: 676

Answers (2)

Walter Tross
Walter Tross

Reputation: 12624

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.

Upvotes: 3

Ted
Ted

Reputation: 3260

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

Upvotes: 1

Related Questions