From bc18758a508df0ff39a80f6b9f30e2cb4d7816a3 Mon Sep 17 00:00:00 2001 From: Marti Maria Date: Thu, 21 Apr 2011 17:53:14 +0200 Subject: Fixed a bug in black preservation and sligtly non-monotonic curves --- src/cmsgamma.c | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) (limited to 'src/cmsgamma.c') diff --git a/src/cmsgamma.c b/src/cmsgamma.c index db156c7..02dc910 100644 --- a/src/cmsgamma.c +++ b/src/cmsgamma.c @@ -1008,20 +1008,42 @@ cmsBool CMSEXPORT cmsIsToneCurveMonotonic(const cmsToneCurve* t) { int n; int i, last; + cmsBool lDescending; _cmsAssert(t != NULL); + + // Degenerated curves are monotonic? Ok, let's pass them + n = t ->nEntries; + if (n < 2) return TRUE; - n = t ->nEntries; - last = t ->Table16[n-1]; + // Curve direction + lDescending = cmsIsToneCurveDescending(t); + + if (lDescending) { - for (i = n-2; i >= 0; --i) { + last = t ->Table16[0]; - if (t ->Table16[i] > last) + for (i = 1; i < n; i++) { - return FALSE; - else - last = t ->Table16[i]; + if (t ->Table16[i] - last > 2) // We allow some ripple + return FALSE; + else + last = t ->Table16[i]; + } + } + else { + + last = t ->Table16[n-1]; + + for (i = n-2; i >= 0; --i) { + + if (t ->Table16[i] - last > 2) + return FALSE; + else + last = t ->Table16[i]; + + } } return TRUE; -- cgit v1.2.1