diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2011-04-06 13:16:56 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2011-04-06 13:16:56 +0200 |
commit | 22ad7c043fa3e9b9f23b5ba1960b8c8d90c08f9e (patch) | |
tree | aa4a574de9478050eccde9d50bf37a2a0d645c63 | |
parent | 4156e3fd2e8c70faea1d5f39170e7629ed451a2a (diff) | |
download | mupdf-22ad7c043fa3e9b9f23b5ba1960b8c8d90c08f9e.tar.xz |
Improve L*a*b to RGB color conversion.
-rw-r--r-- | pdf/pdf_colorspace.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/pdf/pdf_colorspace.c b/pdf/pdf_colorspace.c index 11316fbe..a98e649b 100644 --- a/pdf/pdf_colorspace.c +++ b/pdf/pdf_colorspace.c @@ -39,19 +39,25 @@ static inline float invg(float x) } static void -lab_to_xyz(fz_colorspace *cs, float *lab, float *xyz) +lab_to_xyz(fz_colorspace *cs, float *lab, float *rgb) { /* input is in range (0..100, -128..127, -128..127) not (0..1, 0..1, 0..1) */ - float lstar, astar, bstar, l, m, n; + float lstar, astar, bstar, l, m, n, x, y, z, r, g, b; lstar = lab[0]; astar = lab[1]; bstar = lab[2]; m = (lstar + 16) / 116; l = m + astar / 500; n = m - bstar / 200; - xyz[0] = fung(l); - xyz[1] = fung(m); - xyz[2] = fung(n); + x = fung(l); + y = fung(m); + z = fung(n); + r = (3.240449f * x + -1.537136f * y + -0.498531f * z) * 0.830026f; + g = (-0.969265f * x + 1.876011f * y + 0.041556f * z) * 1.05452f; + b = (0.055643f * x + -0.204026f * y + 1.057229f * z) * 1.1003f; + rgb[0] = sqrtf(CLAMP(r, 0, 1)); + rgb[1] = sqrtf(CLAMP(g, 0, 1)); + rgb[2] = sqrtf(CLAMP(b, 0, 1)); } static void |