Add support for bitmaps with header size 56

Size 56 is the undocumented `BITMAPV3INFOHEADER`.
It adds the alpha bit mask.

The format is known to be supported by:
- Windows (MS paint, etc.)
- Adobe Photoshop
- Popular web browsers
This commit is contained in:
Jonah Jeleniewski 2024-04-08 21:16:39 +10:00
parent 2f3281dcda
commit a1a2202ebe
3 changed files with 3 additions and 2 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

View File

@ -45,6 +45,7 @@ def test_questionable() -> None:
"pal8rletrns.bmp", "pal8rletrns.bmp",
"rgb32bf-xbgr.bmp", "rgb32bf-xbgr.bmp",
"rgb32h52.bmp", "rgb32h52.bmp",
"rgba32h56.bmp",
] ]
for f in get_files("q"): for f in get_files("q"):
try: try:

View File

@ -53,7 +53,7 @@ def _accept(prefix: bytes) -> bool:
def _dib_accept(prefix): def _dib_accept(prefix):
return i32(prefix) in [12, 40, 52, 64, 108, 124] return i32(prefix) in [12, 40, 52, 56, 64, 108, 124]
# ============================================================================= # =============================================================================
@ -95,7 +95,7 @@ class BmpImageFile(ImageFile.ImageFile):
# --------------------------------------------- Windows Bitmap v2 to v5 # --------------------------------------------- Windows Bitmap v2 to v5
# v3, OS/2 v2, v4, v5 # v3, OS/2 v2, v4, v5
elif file_info["header_size"] in (40, 52, 64, 108, 124): elif file_info["header_size"] in (40, 52, 56, 64, 108, 124):
file_info["y_flip"] = header_data[7] == 0xFF file_info["y_flip"] = header_data[7] == 0xFF
file_info["direction"] = 1 if file_info["y_flip"] else -1 file_info["direction"] = 1 if file_info["y_flip"] else -1
file_info["width"] = i32(header_data, 0) file_info["width"] = i32(header_data, 0)