mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-05-04 16:03:42 +03:00
Merge pull request #5549 from radarhere/palette
This commit is contained in:
commit
53b51e1df6
|
@ -65,10 +65,15 @@ def test_sanity(tmp_path):
|
||||||
roundtrip(original_im)
|
roundtrip(original_im)
|
||||||
|
|
||||||
|
|
||||||
def test_palette_depth_16():
|
def test_palette_depth_16(tmp_path):
|
||||||
with Image.open("Tests/images/p_16.tga") as im:
|
with Image.open("Tests/images/p_16.tga") as im:
|
||||||
assert_image_equal_tofile(im.convert("RGB"), "Tests/images/p_16.png")
|
assert_image_equal_tofile(im.convert("RGB"), "Tests/images/p_16.png")
|
||||||
|
|
||||||
|
out = str(tmp_path / "temp.png")
|
||||||
|
im.save(out)
|
||||||
|
with Image.open(out) as reloaded:
|
||||||
|
assert_image_equal_tofile(reloaded.convert("RGB"), "Tests/images/p_16.png")
|
||||||
|
|
||||||
|
|
||||||
def test_id_field():
|
def test_id_field():
|
||||||
# tga file with id field
|
# tga file with id field
|
||||||
|
|
|
@ -830,7 +830,7 @@ class Image:
|
||||||
arr = bytes(
|
arr = bytes(
|
||||||
value for (index, value) in enumerate(arr) if index % 4 != 3
|
value for (index, value) in enumerate(arr) if index % 4 != 3
|
||||||
)
|
)
|
||||||
self.im.putpalette(mode, arr)
|
palette_length = self.im.putpalette(mode, arr)
|
||||||
self.palette.dirty = 0
|
self.palette.dirty = 0
|
||||||
self.palette.rawmode = None
|
self.palette.rawmode = None
|
||||||
if "transparency" in self.info:
|
if "transparency" in self.info:
|
||||||
|
@ -841,6 +841,7 @@ class Image:
|
||||||
self.palette.mode = "RGBA"
|
self.palette.mode = "RGBA"
|
||||||
else:
|
else:
|
||||||
self.palette.mode = "RGB"
|
self.palette.mode = "RGB"
|
||||||
|
self.palette.palette = self.im.getpalette()[: palette_length * 3]
|
||||||
|
|
||||||
if self.im:
|
if self.im:
|
||||||
if cffi and USE_CFFI_ACCESS:
|
if cffi and USE_CFFI_ACCESS:
|
||||||
|
|
|
@ -1663,8 +1663,7 @@ _putpalette(ImagingObject *self, PyObject *args) {
|
||||||
|
|
||||||
unpack(self->image->palette->palette, palette, palettesize * 8 / bits);
|
unpack(self->image->palette->palette, palette, palettesize * 8 / bits);
|
||||||
|
|
||||||
Py_INCREF(Py_None);
|
return PyLong_FromLong(palettesize * 8 / bits);
|
||||||
return Py_None;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
|
Loading…
Reference in New Issue
Block a user