I'm trying to implement a simple 8-bit run length encoder. For my testing, I am using the pixel data of a 100x100 black bitmap image. It is saved as a 24 bit image, this resulting in 100 * 100 * 30 = 30000 bytes of pixel data, all of which are 0x00.
So I know the nature of RLE8 is [1 byte header][1 byte data].
So doing the math, I came up with:
236 occurrences of 0xFF 0x00 and 1 occurrence of 0x9C 0x00, totaling with 474 bytes, preceded by a bitmap header.
My code outputs this as expected, but when I try to open my image with paint or some other paint-like programs, it fails. I am sure to change my bitmap header correctly.
A couple questions I have:Code:bitmapfileheader.size = 474 + 54; bitmapinfoheader.compression = 1;
Do I need to change bitmapinfoheader.size to 30000, which is the uncompressed number of pixel data? I have tried it both ways, being 0 or 30000, and neither have made a difference.
Could it be that many of these paint programs don't support RLE8 encoded bitmaps?
If you need to see code, I would be more than happy to post some, but hopefully having a basic image should help as well.
Thanks ahead of time!
Edit: Just thought of something, can you even encode a 24-bit image a RLE8, or must you stick with an encoding that has the same data size, like RLE24?