summaryrefslogtreecommitdiff
path: root/src/cmsgamma.c
diff options
context:
space:
mode:
authorMarti Maria <info@littlecms.com>2011-04-21 17:53:14 +0200
committerMarti Maria <info@littlecms.com>2011-04-21 17:53:14 +0200
commitbc18758a508df0ff39a80f6b9f30e2cb4d7816a3 (patch)
treeadcd9dc4ef7e9a2e86327424f0984d8dc0fdb6cf /src/cmsgamma.c
parent70a120d7e45e33efc8d2a8475abcd7e83d99f474 (diff)
downloadlcms2-bc18758a508df0ff39a80f6b9f30e2cb4d7816a3.tar.gz
Fixed a bug in black preservation and sligtly non-monotonic curves
Diffstat (limited to 'src/cmsgamma.c')
-rw-r--r--src/cmsgamma.c36
1 files changed, 29 insertions, 7 deletions
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;