mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 01:46:18 +03:00
mapdepth is only 1 byte
This commit is contained in:
parent
b01fd46fe6
commit
04df6e3bf1
BIN
Tests/images/200x32_p_bl_raw_origin.tga
Normal file
BIN
Tests/images/200x32_p_bl_raw_origin.tga
Normal file
Binary file not shown.
|
@ -6,7 +6,7 @@ import pytest
|
||||||
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
from .helper import assert_image_equal, hopper
|
from .helper import assert_image_equal, assert_image_equal_tofile, hopper
|
||||||
|
|
||||||
_TGA_DIR = os.path.join("Tests", "images", "tga")
|
_TGA_DIR = os.path.join("Tests", "images", "tga")
|
||||||
_TGA_DIR_COMMON = os.path.join(_TGA_DIR, "common")
|
_TGA_DIR_COMMON = os.path.join(_TGA_DIR, "common")
|
||||||
|
@ -112,6 +112,14 @@ def test_save_wrong_mode(tmp_path):
|
||||||
im.save(out)
|
im.save(out)
|
||||||
|
|
||||||
|
|
||||||
|
def test_save_mapdepth():
|
||||||
|
# This image has been manually hexedited from 200x32_p_bl_raw.tga
|
||||||
|
# to include an origin
|
||||||
|
test_file = "Tests/images/200x32_p_bl_raw_origin.tga"
|
||||||
|
with Image.open(test_file) as im:
|
||||||
|
assert_image_equal_tofile(im, "Tests/images/tga/common/200x32_p.png")
|
||||||
|
|
||||||
|
|
||||||
def test_save_id_section(tmp_path):
|
def test_save_id_section(tmp_path):
|
||||||
test_file = "Tests/images/rgb32rle.tga"
|
test_file = "Tests/images/rgb32rle.tga"
|
||||||
with Image.open(test_file) as im:
|
with Image.open(test_file) as im:
|
||||||
|
|
|
@ -110,7 +110,7 @@ class TgaImageFile(ImageFile.ImageFile):
|
||||||
|
|
||||||
if colormaptype:
|
if colormaptype:
|
||||||
# read palette
|
# read palette
|
||||||
start, size, mapdepth = i16(s, 3), i16(s, 5), i16(s, 7)
|
start, size, mapdepth = i16(s, 3), i16(s, 5), s[7]
|
||||||
if mapdepth == 16:
|
if mapdepth == 16:
|
||||||
self.palette = ImagePalette.raw(
|
self.palette = ImagePalette.raw(
|
||||||
"BGR;16", b"\0" * 2 * start + self.fp.read(2 * size)
|
"BGR;16", b"\0" * 2 * start + self.fp.read(2 * size)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user