From af6d16923fab4597e364c891fee2deb89998bdde Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Thu, 31 Mar 2011 15:04:30 +0200 Subject: xps: Fix bugs in TIFF reader. WhiteIsBlack was flipped for fax images. re-multiplying alpha with CMYK images needs special care because of subtractive colors. --- fitz/res_pixmap.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'fitz') diff --git a/fitz/res_pixmap.c b/fitz/res_pixmap.c index b37b7a3e..93fdb307 100644 --- a/fitz/res_pixmap.c +++ b/fitz/res_pixmap.c @@ -103,14 +103,32 @@ fz_premultiplypixmap(fz_pixmap *pix) unsigned char *s = pix->samples; unsigned char a; int k, x, y; - for (y = 0; y < pix->h; y++) + + /* special case for CMYK (subtractive colors) */ + if (pix->n == 5) + { + for (y = 0; y < pix->h; y++) + { + for (x = 0; x < pix->w; x++) + { + a = s[pix->n - 1]; + for (k = 0; k < pix->n - 1; k++) + s[k] = 255 - fz_mul255(255 - s[k], a); + s += pix->n; + } + } + } + else { - for (x = 0; x < pix->w; x++) + for (y = 0; y < pix->h; y++) { - a = s[pix->n - 1]; - for (k = 0; k < pix->n - 1; k++) - s[k] = fz_mul255(s[k], a); - s += pix->n; + for (x = 0; x < pix->w; x++) + { + a = s[pix->n - 1]; + for (k = 0; k < pix->n - 1; k++) + s[k] = fz_mul255(s[k], a); + s += pix->n; + } } } } -- cgit v1.2.3