diff --git a/PIL/BmpImagePlugin.py b/PIL/BmpImagePlugin.py index eccd29923..a922d8ff8 100644 --- a/PIL/BmpImagePlugin.py +++ b/PIL/BmpImagePlugin.py @@ -136,12 +136,13 @@ class BmpImageFile(ImageFile.ImageFile): # ----------------- 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)], + 32: [(0xff0000, 0xff00, 0xff, 0x0), (0xff0000, 0xff00, 0xff, 0xff000000), (0x0, 0x0, 0x0, 0x0), (0xff000000, 0xff0000, 0xff00, 0x0) ], 24: [(0xff0000, 0xff00, 0xff)], 16: [(0xf800, 0x7e0, 0x1f), (0x7c00, 0x3e0, 0x1f)] } MASK_MODES = { (32, (0xff0000, 0xff00, 0xff, 0x0)): "BGRX", + (32, (0xff000000, 0xff0000, 0xff00, 0x0)): "XBGR", (32, (0xff0000, 0xff00, 0xff, 0xff000000)): "BGRA", (32, (0x0, 0x0, 0x0, 0x0)): "BGRA", (24, (0xff0000, 0xff00, 0xff)): "BGR", diff --git a/Tests/images/bmp/q/rgb32bf-xbgr.bmp b/Tests/images/bmp/q/rgb32bf-xbgr.bmp new file mode 100644 index 000000000..c6c05e148 Binary files /dev/null and b/Tests/images/bmp/q/rgb32bf-xbgr.bmp differ diff --git a/Tests/test_bmp_reference.py b/Tests/test_bmp_reference.py index b6f0b4564..0f98d8374 100644 --- a/Tests/test_bmp_reference.py +++ b/Tests/test_bmp_reference.py @@ -26,12 +26,26 @@ class TestBmpReference(PillowTestCase): def test_questionable(self): """ These shouldn't crash/dos, but it's not well defined that these are in spec """ + supported = [ + "pal8os2v2.bmp", + "rgb24prof.bmp", + "pal1p1.bmp", + "pal8offs.bmp", + "rgb24lprof.bmp", + "rgb32fakealpha.bmp", + "rgb24largepal.bmp", + "pal8os2sp.bmp", + "rgb32bf-xbgr.bmp", + ] for f in self.get_files('q'): try: im = Image.open(f) im.load() + if os.path.basename(f) not in supported: + print("Please add %s to the partially supported bmp specs." % f) except Exception: # as msg: - pass + if os.path.basename(f) in supported: + raise # print ("Bad Image %s: %s" %(f,msg)) def test_good(self):