mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-05-03 07:23:41 +03:00
Added mode descriptors for all I;16 modes
This commit is contained in:
parent
e8af68bae2
commit
b262378632
|
@ -26,6 +26,17 @@ class TestImageMode(PillowTestCase):
|
||||||
self.assertEqual(m.basemode, "L")
|
self.assertEqual(m.basemode, "L")
|
||||||
self.assertEqual(m.basetype, "L")
|
self.assertEqual(m.basetype, "L")
|
||||||
|
|
||||||
|
for mode in ("I;16", "I;16S",
|
||||||
|
"I;16L", "I;16LS",
|
||||||
|
"I;16B", "I;16BS",
|
||||||
|
"I;16N", "I;16NS"):
|
||||||
|
m = ImageMode.getmode(mode)
|
||||||
|
self.assertEqual(m.mode, mode)
|
||||||
|
self.assertEqual(str(m), mode)
|
||||||
|
self.assertEqual(m.bands, ("I",))
|
||||||
|
self.assertEqual(m.basemode, "L")
|
||||||
|
self.assertEqual(m.basetype, "L")
|
||||||
|
|
||||||
m = ImageMode.getmode("RGB")
|
m = ImageMode.getmode("RGB")
|
||||||
self.assertEqual(m.mode, "RGB")
|
self.assertEqual(m.mode, "RGB")
|
||||||
self.assertEqual(str(m), "RGB")
|
self.assertEqual(str(m), "RGB")
|
||||||
|
|
|
@ -48,9 +48,17 @@ def getmode(mode):
|
||||||
modes["La"] = ModeDescriptor("La", ("L", "a"), "L", "L")
|
modes["La"] = ModeDescriptor("La", ("L", "a"), "L", "L")
|
||||||
modes["PA"] = ModeDescriptor("PA", ("P", "A"), "RGB", "L")
|
modes["PA"] = ModeDescriptor("PA", ("P", "A"), "RGB", "L")
|
||||||
# mapping modes
|
# mapping modes
|
||||||
modes["I;16"] = ModeDescriptor("I;16", "I", "L", "L")
|
for i16mode in (
|
||||||
modes["I;16L"] = ModeDescriptor("I;16L", "I", "L", "L")
|
"I;16",
|
||||||
modes["I;16B"] = ModeDescriptor("I;16B", "I", "L", "L")
|
"I;16S",
|
||||||
|
"I;16L",
|
||||||
|
"I;16LS",
|
||||||
|
"I;16B",
|
||||||
|
"I;16BS",
|
||||||
|
"I;16N",
|
||||||
|
"I;16NS",
|
||||||
|
):
|
||||||
|
modes[i16mode] = ModeDescriptor(i16mode, ("I",), "L", "L")
|
||||||
# set global mode cache atomically
|
# set global mode cache atomically
|
||||||
_modes = modes
|
_modes = modes
|
||||||
return _modes[mode]
|
return _modes[mode]
|
||||||
|
|
|
@ -63,17 +63,11 @@ class Viewer(object):
|
||||||
def show(self, image, **options):
|
def show(self, image, **options):
|
||||||
|
|
||||||
# save temporary image to disk
|
# save temporary image to disk
|
||||||
if image.mode[:4] == "I;16":
|
if not (
|
||||||
# @PIL88 @PIL101
|
image.mode in ("1", "RGBA") or (self.format == "PNG" and image.mode == "LA")
|
||||||
# "I;16" isn't an 'official' mode, but we still want to
|
):
|
||||||
# provide a simple way to show 16-bit images.
|
|
||||||
base = "L"
|
|
||||||
# FIXME: auto-contrast if max() > 255?
|
|
||||||
else:
|
|
||||||
base = Image.getmodebase(image.mode)
|
base = Image.getmodebase(image.mode)
|
||||||
if not (base == image.mode or
|
if image.mode != base:
|
||||||
image.mode in ("1", "RGBA") or
|
|
||||||
(self.format == "PNG" and image.mode == "LA")):
|
|
||||||
image = image.convert(base)
|
image = image.convert(base)
|
||||||
|
|
||||||
return self.show_image(image, **options)
|
return self.show_image(image, **options)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user