Skip to content

Commit

Permalink
Added CMYK;16B and CMYK;16N unpackers
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Jun 23, 2019
1 parent 32d1050 commit 1fa85aa
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Tests/test_lib_pack.py
Expand Up @@ -705,6 +705,18 @@ def test_I16(self):
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)
Expand Down
7 changes: 7 additions & 0 deletions src/libImaging/Unpack.c
Expand Up @@ -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},
Expand All @@ -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},
Expand Down

0 comments on commit 1fa85aa

Please sign in to comment.