Skip to content

Conversation

@radarhere
Copy link
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.

@radarhere radarhere added the BMP label Dec 21, 2021
@hugovk hugovk merged commit fccc261 into python-pillow:main Dec 28, 2021
@radarhere radarhere deleted the bmp branch December 28, 2021 08:11
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