mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-03 21:24:31 +03:00
Added CMYK to RGB unpacker
This commit is contained in:
parent
07623d1a7c
commit
00cec60c35
|
@ -340,6 +340,10 @@ class TestLibUnpack:
|
|||
self.assert_unpack("RGB", "G;16N", 2, (0, 1, 0), (0, 3, 0), (0, 5, 0))
|
||||
self.assert_unpack("RGB", "B;16N", 2, (0, 0, 1), (0, 0, 3), (0, 0, 5))
|
||||
|
||||
self.assert_unpack(
|
||||
"RGB", "CMYK", 4, (250, 249, 248), (242, 241, 240), (234, 233, 233)
|
||||
)
|
||||
|
||||
def test_RGBA(self):
|
||||
self.assert_unpack("RGBA", "LA", 2, (1, 1, 1, 2), (3, 3, 3, 4), (5, 5, 5, 6))
|
||||
self.assert_unpack(
|
||||
|
|
|
@ -813,6 +813,20 @@ ImagingUnpackXBGR(UINT8 *_out, const UINT8 *in, int pixels) {
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
cmyk2rgb(UINT8 *_out, const UINT8 *in, int pixels) {
|
||||
int i, nk, tmp;
|
||||
for (i = 0; i < pixels; i++) {
|
||||
nk = 255 - in[3];
|
||||
_out[0] = CLIP8(nk - MULDIV255(in[0], nk, tmp));
|
||||
_out[1] = CLIP8(nk - MULDIV255(in[1], nk, tmp));
|
||||
_out[2] = CLIP8(nk - MULDIV255(in[2], nk, tmp));
|
||||
_out[3] = 255;
|
||||
_out += 4;
|
||||
in += 4;
|
||||
}
|
||||
}
|
||||
|
||||
/* Unpack to "RGBA" image */
|
||||
|
||||
static void
|
||||
|
@ -1589,6 +1603,7 @@ static struct {
|
|||
{"RGB", "R;16B", 16, band016B},
|
||||
{"RGB", "G;16B", 16, band116B},
|
||||
{"RGB", "B;16B", 16, band216B},
|
||||
{"RGB", "CMYK", 32, cmyk2rgb},
|
||||
|
||||
/* true colour w. alpha */
|
||||
{"RGBA", "LA", 16, unpackRGBALA},
|
||||
|
|
Loading…
Reference in New Issue
Block a user