Skip to content

Commit d2fc1bd

Browse files
committed
use new rawmodes in BMP and TGA image plugins
1 parent 0206464 commit d2fc1bd

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/PIL/BmpImagePlugin.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
1: ("P", "P;1"),
4444
4: ("P", "P;4"),
4545
8: ("P", "P"),
46-
16: ("RGB", "BGR;15"),
46+
16: ("RGB", "XRGB;1555"),
4747
24: ("RGB", "BGR"),
4848
32: ("RGB", "BGRX"),
4949
}
@@ -205,8 +205,8 @@ def _bitmap(self, header=0, offset=0):
205205
(32, (0xFF000000, 0xFF00, 0xFF, 0xFF0000)): "BGAR",
206206
(32, (0x0, 0x0, 0x0, 0x0)): "BGRA",
207207
(24, (0xFF0000, 0xFF00, 0xFF)): "BGR",
208-
(16, (0xF800, 0x7E0, 0x1F)): "BGR;16",
209-
(16, (0x7C00, 0x3E0, 0x1F)): "BGR;15",
208+
(16, (0xF800, 0x7E0, 0x1F)): "RGB;565",
209+
(16, (0x7C00, 0x3E0, 0x1F)): "XRGB;1555",
210210
}
211211
if file_info["bits"] in SUPPORTED:
212212
if (

src/PIL/TgaImagePlugin.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
(3, 1): "1",
3737
(3, 8): "L",
3838
(3, 16): "LA",
39-
(2, 16): "BGR;5",
39+
(2, 16): "ARGB;1555",
4040
(2, 24): "BGR",
4141
(2, 32): "BGRA",
4242
}
@@ -118,8 +118,9 @@ def _open(self) -> None:
118118
start, size, mapdepth = i16(s, 3), i16(s, 5), s[7]
119119
if mapdepth == 16:
120120
self.palette = ImagePalette.raw(
121-
"BGR;15", b"\0" * 2 * start + self.fp.read(2 * size)
121+
"ARGB;1555", b"\0" * 2 * start + self.fp.read(2 * size)
122122
)
123+
self.palette.mode = "RGBA"
123124
elif mapdepth == 24:
124125
self.palette = ImagePalette.raw(
125126
"BGR", b"\0" * 3 * start + self.fp.read(3 * size)

0 commit comments

Comments
 (0)