문제

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

도움이 되었습니까?

해결책

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.

다른 팁

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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top