Skip to content

Commit

Permalink
use new rawmodes in BMP and TGA image plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
Yay295 committed Jun 15, 2024
1 parent 0206464 commit d2fc1bd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/PIL/BmpImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
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"),
}
Expand Down Expand Up @@ -205,8 +205,8 @@ def _bitmap(self, header=0, offset=0):
(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 (
Expand Down
5 changes: 3 additions & 2 deletions src/PIL/TgaImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
(3, 1): "1",
(3, 8): "L",
(3, 16): "LA",
(2, 16): "BGR;5",
(2, 16): "ARGB;1555",
(2, 24): "BGR",
(2, 32): "BGRA",
}
Expand Down Expand Up @@ -118,8 +118,9 @@ def _open(self) -> None:
start, size, mapdepth = i16(s, 3), i16(s, 5), s[7]
if mapdepth == 16:
self.palette = ImagePalette.raw(
"BGR;15", b"\0" * 2 * start + self.fp.read(2 * size)
"ARGB;1555", b"\0" * 2 * start + self.fp.read(2 * size)
)
self.palette.mode = "RGBA"
elif mapdepth == 24:
self.palette = ImagePalette.raw(
"BGR", b"\0" * 3 * start + self.fp.read(3 * size)
Expand Down

0 comments on commit d2fc1bd

Please sign in to comment.