Added ABGR MASK_MODE

This commit is contained in:
Andrew Murray 2022-07-14 07:25:28 +10:00
parent 2b9d48403a
commit 9f6a315092
3 changed files with 9 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

View File

@ -129,6 +129,13 @@ def test_rgba_bitfields():
assert_image_equal_tofile(im, "Tests/images/bmp/q/rgb32bf-xbgr.bmp")
# This test image has been manually hexedited
# to change the bitfield compression in the header from XBGR to ABGR
with Image.open("Tests/images/rgb32bf-abgr.bmp") as im:
assert_image_equal_tofile(
im.convert("RGB"), "Tests/images/bmp/q/rgb32bf-xbgr.bmp"
)
def test_rle8():
with Image.open("Tests/images/hopper_rle8.bmp") as im:

View File

@ -173,6 +173,7 @@ class BmpImageFile(ImageFile.ImageFile):
32: [
(0xFF0000, 0xFF00, 0xFF, 0x0),
(0xFF000000, 0xFF0000, 0xFF00, 0x0),
(0xFF000000, 0xFF0000, 0xFF00, 0xFF),
(0xFF, 0xFF00, 0xFF0000, 0xFF000000),
(0xFF0000, 0xFF00, 0xFF, 0xFF000000),
(0x0, 0x0, 0x0, 0x0),
@ -183,6 +184,7 @@ class BmpImageFile(ImageFile.ImageFile):
MASK_MODES = {
(32, (0xFF0000, 0xFF00, 0xFF, 0x0)): "BGRX",
(32, (0xFF000000, 0xFF0000, 0xFF00, 0x0)): "XBGR",
(32, (0xFF000000, 0xFF0000, 0xFF00, 0xFF)): "ABGR",
(32, (0xFF, 0xFF00, 0xFF0000, 0xFF000000)): "RGBA",
(32, (0xFF0000, 0xFF00, 0xFF, 0xFF000000)): "BGRA",
(32, (0x0, 0x0, 0x0, 0x0)): "BGRA",