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

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

Merged
merged 1 commit into from Dec 28, 2021

Conversation

radarhere
Copy link
Member

@radarhere radarhere commented Dec 21, 2021

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
49 checks passed
@radarhere radarhere deleted the bmp branch Dec 28, 2021
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.

2 participants