use new rawmodes in BMP and TGA image plugins

This commit is contained in:
Yay295 2024-05-01 14:05:11 -05:00
parent a43e1f8118
commit 8b719e9401
3 changed files with 6 additions and 6 deletions

View File

@ -85,7 +85,7 @@ def test_rgba_16() -> None:
with Image.open("Tests/images/rgba16.tga") as im:
assert im.mode == "RGBA"
assert im.getpixel((0, 0)) == (172, 0, 255, 255)
assert im.getpixel((0, 0)) == (173, 0, 255, 255)
assert im.getpixel((1, 0)) == (0, 255, 82, 0)

View File

@ -43,7 +43,7 @@ BIT2MODE = {
1: ("P", "P;1"),
4: ("P", "P;4"),
8: ("P", "P"),
16: ("RGB", "BGR;15"),
16: ("RGB", "XRGB;1555"),
24: ("RGB", "BGR"),
32: ("RGB", "BGRX"),
}
@ -218,8 +218,8 @@ class BmpImageFile(ImageFile.ImageFile):
(32, (0xFF000000, 0xFF00, 0xFF, 0xFF0000)): "BGAR",
(32, (0x0, 0x0, 0x0, 0x0)): "BGRA",
(24, (0xFF0000, 0xFF00, 0xFF)): "BGR",
(16, (0xF800, 0x7E0, 0x1F)): "BGR;16",
(16, (0x7C00, 0x3E0, 0x1F)): "BGR;15",
(16, (0xF800, 0x7E0, 0x1F)): "RGB;565",
(16, (0x7C00, 0x3E0, 0x1F)): "XRGB;1555",
}
if file_info["bits"] in SUPPORTED:
if (

View File

@ -36,7 +36,7 @@ MODES = {
(3, 1): "1",
(3, 8): "L",
(3, 16): "LA",
(2, 16): "BGRA;15Z",
(2, 16): "ARGB;1555Z",
(2, 24): "BGR",
(2, 32): "BGRA",
}
@ -116,7 +116,7 @@ class TgaImageFile(ImageFile.ImageFile):
start, size, mapdepth = i16(s, 3), i16(s, 5), s[7]
if mapdepth == 16:
self.palette = ImagePalette.raw(
"BGRA;15Z", bytes(2 * start) + self.fp.read(2 * size)
"ARGB;1555Z", bytes(2 * start) + self.fp.read(2 * size)
)
self.palette.mode = "RGBA"
elif mapdepth == 24: