jsummers / bmpsuite

A set of Windows BMP image files, for testing purposes
https://entropymine.com/jason/bmpsuite/
GNU General Public License v3.0
56 stars 16 forks source link

I think Huffman example is incorrect #16

Closed ColinPitrat closed 3 years ago

ColinPitrat commented 3 years ago

I know you say it yourself:

My attempt to make a BMP file with Huffman 1D compression. It is quite possibly incorrect. Even if everything else about it is correct, I have no way to know whether it is black/white reversed, and/or flipped vertically.

But I think it's incorrect only because it's missing the RTC at the end. From http://zig.tgschultz.com/bmp_file_format.txt the data should end with 6x EOL (End of line), also called RTC (Return to control) to signal the end of file.

My code manages to read and display your BMP fine as long as I hardcode to stop after 64 lines, because it seems it never finds the RTC.

jsummers commented 3 years ago

Thanks for reporting this.

The bmp_file_format.txt document doesn't help matters by saying that the data "ends with an EOL code", then immediately contradicting itself and implying that it ends with an RTC code.

I'll probably change the file to end with an RTC. (attached)

Note that I still don't know the correct bit order, or the effect of the color table.

pal1huff-2.zip

ColinPitrat commented 3 years ago

I don't know for the bit order but the same document mentions:

"White" and "black" are, in this case, not necessarily the colors white and black, but rather the colors represented by palette indexes 0 and 1, respectively.