And finally ?

Error happening in Python 3.x with P images:
in original code, palette data was created from a list of bytestrings. Changed to a full bytestring.
- `b"".join(list of bytestrings)` works in python 2.7 and 3.x
- `b"".join(bytestring)` works in python 2.7 but fails in python 3.x
No need to `join` anymore. Works in 3.x
This commit is contained in:
artscoop 2015-03-05 12:17:52 +01:00
parent 310684521a
commit 8c003e9b3f

View File

@ -126,7 +126,6 @@ class BmpImageFile(ImageFile.ImageFile):
self.mode, raw_mode = BIT2MODE.get(file_info['bits'], (None, None))
if self.mode is None:
raise IOError("Unsupported BMP pixel depth (%d)" % file_info['bits'])
#------------------ Process BMP with Bitfields compression (not palette)
if file_info['compression'] == self.BITFIELDS:
SUPPORTED = {32: [(0xff0000, 0xff00, 0xff, 0x0), (0xff0000, 0xff00, 0xff, 0xff000000), (0x0, 0x0, 0x0, 0x0)], 24: [(0xff0000, 0xff00, 0xff)], 16: [(0xf800, 0x7e0, 0x1f), (0x7c00, 0x3e0, 0x1f)]}
@ -167,7 +166,7 @@ class BmpImageFile(ImageFile.ImageFile):
raw_mode = self.mode
else:
self.mode = "P"
self.palette = ImagePalette.raw("BGRX" if padding == 4 else "BGR", b"".join(palette))
self.palette = ImagePalette.raw("BGRX" if padding == 4 else "BGR", palette)
#------------------------------ Finally set the tile data for the plugin
self.info['compression'] = file_info['compression']