Added CMYK;16B and CMYK;16N unpackers

This commit is contained in:
Andrew Murray 2019-06-23 11:56:17 +10:00
parent 32d10505a3
commit 9c37933bb9
2 changed files with 15 additions and 0 deletions

View File

@ -705,6 +705,14 @@ class TestLibUnpack(PillowTestCase):
self.assert_unpack("I;16B", "I;16N", 2, 0x0102, 0x0304, 0x0506)
self.assert_unpack("I;16L", "I;16N", 2, 0x0102, 0x0304, 0x0506)
def test_CMYK16(self):
self.assert_unpack("CMYK", "CMYK;16L", 8, (2, 4, 6, 8), (10, 12, 14, 16))
self.assert_unpack("CMYK", "CMYK;16B", 8, (1, 3, 5, 7), (9, 11, 13, 15))
if sys.byteorder == "little":
self.assert_unpack("CMYK", "CMYK;16N", 8, (2, 4, 6, 8), (10, 12, 14, 16))
else:
self.assert_unpack("CMYK", "CMYK;16N", 8, (1, 3, 5, 7), (9, 11, 13, 15))
def test_value_error(self):
self.assertRaises(ValueError, self.assert_unpack, "L", "L", 0, 0)
self.assertRaises(ValueError, self.assert_unpack, "RGB", "RGB", 2, 0)

View File

@ -1418,6 +1418,7 @@ static struct {
{"CMYK", "CMYK;I", 32, unpackCMYKI},
{"CMYK", "CMYK;L", 32, unpackRGBAL},
{"CMYK", "CMYK;16L", 64, unpackRGBA16L},
{"CMYK", "CMYK;16B", 64, unpackRGBA16B},
{"CMYK", "C", 8, band0},
{"CMYK", "M", 8, band1},
{"CMYK", "Y", 8, band2},
@ -1427,6 +1428,12 @@ static struct {
{"CMYK", "Y;I", 8, band2I},
{"CMYK", "K;I", 8, band3I},
#ifdef WORDS_BIGENDIAN
{"CMYK", "CMYK;16N", 64, unpackRGBA16B},
#else
{"CMYK", "CMYK;16N", 64, unpackRGBA16L},
#endif
/* video (YCbCr) */
{"YCbCr", "YCbCr", 24, ImagingUnpackRGB},
{"YCbCr", "YCbCr;L", 24, unpackRGBL},