Skip to content

Ensure that BMP pixel data offset does not ignore palette#5899

Merged
hugovk merged 1 commit intopython-pillow:mainfrom
radarhere:bmp
Dec 28, 2021
Merged

Ensure that BMP pixel data offset does not ignore palette#5899
hugovk merged 1 commit intopython-pillow:mainfrom
radarhere:bmp

Conversation

@radarhere
Copy link
Copy Markdown
Member

Resolves #5246

The BMP image in that issue has offset (PixelDataOffset in the linked documentation) to the image data of 54, ignoring the palette.

https://medium.com/sysf/bits-to-bitmaps-a-simple-walkthrough-of-bmp-image-format-765dc6857393

We also need to adjust PixelDataOffset the value accordingly by considering the size of the Color Pallet block.

So I think this is a mistake. This PR tolerates that though, by adding the palette size to the offset, if the offset is just the total size of the header.

The documentation states that the size of palette block is

In nutshell, the total size of this block is 4 x N bytes where N is the total entries in the color pallet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Strange image shift in .bmp files

2 participants