mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-11 04:07:21 +03:00
1bpp BMP fix
It appears that {{{ The handling of 1bpp bitmaps is a little complicated. When reading 1bpp bitmaps, the palette is ignored. 1's are considered foreground, and they are considered black. 0's are considered background, and they are considered white. }}} so the raw mode has to be `1;I`
This commit is contained in:
parent
c0ce8d0ae8
commit
877c138e21
|
@ -162,7 +162,7 @@ class BmpImageFile(ImageFile.ImageFile):
|
|||
#--------- If all colors are grey, white or black, ditch palette
|
||||
if greyscale:
|
||||
self.mode = "1" if file_info['colors'] == 2 else "L"
|
||||
raw_mode = self.mode
|
||||
raw_mode = self.mode if self.mode != "1" else "1;I" # rule for 1bpp : 1=b, 0=w
|
||||
else:
|
||||
self.mode = "P"
|
||||
self.palette = ImagePalette.raw("BGRX", b"".join(palette))
|
||||
|
|
Loading…
Reference in New Issue
Block a user