diff options
author | Tor Andersson <tor@ghostscript.com> | 2011-02-04 10:41:22 +0000 |
---|---|---|
committer | Tor Andersson <tor@ghostscript.com> | 2011-02-04 10:41:22 +0000 |
commit | 957a3b1dab7116ae6e1718aada95dd3373006aed (patch) | |
tree | a15f91363a08ae8692785a006676f994898b3a84 /fitz | |
parent | 1a78cca0bbdd53ed31ccbc3fb028f397fa8d2d06 (diff) | |
download | mupdf-957a3b1dab7116ae6e1718aada95dd3373006aed.tar.xz |
Use the CMYK-to-RGB transform from Poppler.
Diffstat (limited to 'fitz')
-rw-r--r-- | fitz/res_colorspace.c | 65 |
1 files changed, 51 insertions, 14 deletions
diff --git a/fitz/res_colorspace.c b/fitz/res_colorspace.c index ca3cdeb8..f3ea317d 100644 --- a/fitz/res_colorspace.c +++ b/fitz/res_colorspace.c @@ -85,20 +85,57 @@ static void xyztobgr(fz_colorspace *cs, float *xyz, float *bgr) static void cmyktoxyz(fz_colorspace *cs, float *cmyk, float *xyz) { -#ifdef SLOWCMYK /* from xpdf */ - float c = CLAMP(cmyk[0] + cmyk[3], 0, 1); - float m = CLAMP(cmyk[1] + cmyk[3], 0, 1); - float y = CLAMP(cmyk[2] + cmyk[3], 0, 1); - float aw = (1-c) * (1-m) * (1-y); - float ac = c * (1-m) * (1-y); - float am = (1-c) * m * (1-y); - float ay = (1-c) * (1-m) * y; - float ar = (1-c) * m * y; - float ag = c * (1-m) * y; - float ab = c * m * (1-y); - float r = aw + 0.9137*am + 0.9961*ay + 0.9882*ar; - float g = aw + 0.6196*ac + ay + 0.5176*ag; - float b = aw + 0.7804*ac + 0.5412*am + 0.0667*ar + 0.2118*ag + 0.4863*ab; +#ifdef SLOWCMYK /* from poppler */ + float c = cmyk[0], m = cmyk[1], y = cmyk[2], k = cmyk[3]; + float c1 = 1 - c, m1 = 1 - m, y1 = 1 - y, k1 = 1 - k; + float r, g, b, x; + + /* this is a matrix multiplication, unrolled for performance */ + x = c1 * m1 * y1 * k1; /* 0 0 0 0 */ + r = g = b = x; + x = c1 * m1 * y1 * k; /* 0 0 0 1 */ + r += 0.1373 * x; + g += 0.1216 * x; + b += 0.1255 * x; + x = c1 * m1 * y * k1; /* 0 0 1 0 */ + r += x; + g += 0.9490 * x; + x = c1 * m1 * y * k; /* 0 0 1 1 */ + r += 0.1098 * x; + g += 0.1020 * x; + x = c1 * m * y1 * k1; /* 0 1 0 0 */ + r += 0.9255 * x; + b += 0.5490 * x; + x = c1 * m * y1 * k; /* 0 1 0 1 */ + r += 0.1412 * x; + x = c1 * m * y * k1; /* 0 1 1 0 */ + r += 0.9294 * x; + g += 0.1098 * x; + b += 0.1412 * x; + x = c1 * m * y * k; /* 0 1 1 1 */ + r += 0.1333 * x; + x = c * m1 * y1 * k1; /* 1 0 0 0 */ + g += 0.6784 * x; + b += 0.9373 * x; + x = c * m1 * y1 * k; /* 1 0 0 1 */ + g += 0.0588 * x; + b += 0.1412 * x; + x = c * m1 * y * k1; /* 1 0 1 0 */ + g += 0.6510 * x; + b += 0.3137 * x; + x = c * m1 * y * k; /* 1 0 1 1 */ + g += 0.0745 * x; + x = c * m * y1 * k1; /* 1 1 0 0 */ + r += 0.1804 * x; + g += 0.1922 * x; + b += 0.5725 * x; + x = c * m * y1 * k; /* 1 1 0 1 */ + b += 0.0078 * x; + x = c * m * y * k1; /* 1 1 1 0 */ + r += 0.2118 * x; + g += 0.2119 * x; + b += 0.2235 * x; + xyz[0] = CLAMP(r, 0, 1); xyz[1] = CLAMP(g, 0, 1); xyz[2] = CLAMP(b, 0, 1); |