Merge pull request #5400 from radarhere/mapdepth_16

Changed mode for TGA 16-bit palette to BGR;15
This commit is contained in:
Hugo van Kemenade 2021-04-18 13:00:29 +03:00 committed by GitHub
commit fc08a72600
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 1 deletions

BIN
Tests/images/p_16.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 378 B

BIN
Tests/images/p_16.tga Normal file

Binary file not shown.

View File

@ -65,6 +65,11 @@ def test_sanity(tmp_path):
roundtrip(original_im)
def test_palette_depth_16():
with Image.open("Tests/images/p_16.tga") as im:
assert_image_equal_tofile(im.convert("RGB"), "Tests/images/p_16.png")
def test_id_field():
# tga file with id field
test_file = "Tests/images/tga_id_field.tga"

View File

@ -113,7 +113,7 @@ class TgaImageFile(ImageFile.ImageFile):
start, size, mapdepth = i16(s, 3), i16(s, 5), s[7]
if mapdepth == 16:
self.palette = ImagePalette.raw(
"BGR;16", b"\0" * 2 * start + self.fp.read(2 * size)
"BGR;15", b"\0" * 2 * start + self.fp.read(2 * size)
)
elif mapdepth == 24:
self.palette = ImagePalette.raw(