Pixel data offset field from the BMP header is ignored
adzierzanowski opened this issue · 0 comments
The problem
This is somewhat of an edge case. Unlike in mspaint, the field in the header which tells the offset to the pixel data is ignored which results in rendering the data from the usual offset of 54 bytes. (EDIT: Or as I see now, rather the first position of the cursor after parsing all headers).
As you can see, the offset is already parsed:
Line 325 in 12a90c6
Example
This is a BMP file which is purposefully deceitful as it contains two images. When the offset is ignored, the "hidden" text appears in the image. Otherwise it displays just a photo of ice. Opening it in mspaint looks like below. Opening it in jspaint shows the text.
Possible solution
Set location to the offset in the BMPDecoder class, scanImage function:
scanImage(padding = 0, width = this.width, processPixel) {
this.pos = this.offset