diff --git a/Tests/test_file_tga.py b/Tests/test_file_tga.py index a03a6a6e1..26837fcf8 100644 --- a/Tests/test_file_tga.py +++ b/Tests/test_file_tga.py @@ -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) diff --git a/src/PIL/BmpImagePlugin.py b/src/PIL/BmpImagePlugin.py index bf8f29577..a1942d954 100644 --- a/src/PIL/BmpImagePlugin.py +++ b/src/PIL/BmpImagePlugin.py @@ -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 ( diff --git a/src/PIL/TgaImagePlugin.py b/src/PIL/TgaImagePlugin.py index 90d5b5cf4..daf98f353 100644 --- a/src/PIL/TgaImagePlugin.py +++ b/src/PIL/TgaImagePlugin.py @@ -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: