Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pixel data offset field from the BMP header is ignored #323

Open
adzierzanowski opened this issue Aug 4, 2023 · 0 comments
Open

Pixel data offset field from the BMP header is ignored #323

adzierzanowski opened this issue Aug 4, 2023 · 0 comments

Comments

@adzierzanowski
Copy link

adzierzanowski commented Aug 4, 2023

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:

this.offset = this.view.getUint32(this.pos, true); this.pos += 4;

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
adzierzanowski added a commit to adzierzanowski/jspaint that referenced this issue Aug 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant