Skip to content

Conversation

@radarhere
Copy link
Member

@radarhere radarhere commented Apr 22, 2021

Resolves #4911

In an ICO, if the frame mode is "1", that means that it can't determine bpp, since BIT2MODE has no rawmode of "1".

# figure out where AND mask image starts
mode = a[0]
bpp = 8
for k, v in BmpImagePlugin.BIT2MODE.items():
if mode == v[1]:
bpp = k
break

BIT2MODE = {
# bits => mode, rawmode
1: ("P", "P;1"),
4: ("P", "P;4"),
8: ("P", "P"),
16: ("RGB", "BGR;15"),
24: ("RGB", "BGR"),
32: ("RGB", "BGRX"),
}

Instead, allow the file to report its bpp. Test image created using GIMP.

@radarhere radarhere changed the title Use header color depth for ICO bpp Use bpp from ICO header Apr 22, 2021
@hugovk hugovk merged commit 6461dd6 into python-pillow:master Apr 25, 2021
@radarhere radarhere deleted the ico branch April 25, 2021 11:31
akx added a commit to akx/Pillow that referenced this pull request Nov 14, 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

Successfully merging this pull request may close these issues.

Not able to parse particular greyscale .ico file

2 participants