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:
artscoop 2015-03-04 19:26:15 +01:00
parent c0ce8d0ae8
commit 877c138e21

View File

@ -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))