summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarti Maria <info@littlecms.com>2010-11-29 12:21:39 +0100
committerMarti Maria <info@littlecms.com>2010-11-29 12:21:39 +0100
commit4b7be73b283fd6bed89f5d968e9882ec38b9fa8e (patch)
tree4e41e2542d4fb5c5af385d380c2dd2770bb8c616
parent9dab249d60caebed2ac530ab53fcb0231b218c2b (diff)
downloadlcms2-4b7be73b283fd6bed89f5d968e9882ec38b9fa8e.tar.gz
Fixed a bug in floating point interpolation (missing clipping)
-rw-r--r--src/cmsintrp.c36
1 files changed, 30 insertions, 6 deletions
diff --git a/src/cmsintrp.c b/src/cmsintrp.c
index a6e9994..9aced86 100644
--- a/src/cmsintrp.c
+++ b/src/cmsintrp.c
@@ -424,9 +424,21 @@ void TrilinearInterpFloat(const cmsFloat32Number Input[],
TotalOut = p -> nOutputs;
- px = Input[0] * p->Domain[0];
- py = Input[1] * p->Domain[1];
- pz = Input[2] * p->Domain[2];
+ // We need some clipping here
+ px = Input[0];
+ py = Input[1];
+ pz = Input[2];
+
+ if (px < 0) px = 0;
+ if (px > 1) px = 1;
+ if (py < 0) py = 0;
+ if (py > 1) py = 1;
+ if (pz < 0) pz = 0;
+ if (pz > 1) pz = 1;
+
+ px *= p->Domain[0];
+ py *= p->Domain[1];
+ pz *= p->Domain[2];
x0 = (int) _cmsQuickFloor(px); fx = px - (cmsFloat32Number) x0;
y0 = (int) _cmsQuickFloor(py); fy = py - (cmsFloat32Number) y0;
@@ -567,9 +579,21 @@ void TetrahedralInterpFloat(const cmsFloat32Number Input[],
TotalOut = p -> nOutputs;
- px = Input[0] * p->Domain[0];
- py = Input[1] * p->Domain[1];
- pz = Input[2] * p->Domain[2];
+ // We need some clipping here
+ px = Input[0];
+ py = Input[1];
+ pz = Input[2];
+
+ if (px < 0) px = 0;
+ if (px > 1) px = 1;
+ if (py < 0) py = 0;
+ if (py > 1) py = 1;
+ if (pz < 0) pz = 0;
+ if (pz > 1) pz = 1;
+
+ px *= p->Domain[0];
+ py *= p->Domain[1];
+ pz *= p->Domain[2];
x0 = (int) _cmsQuickFloor(px); rx = (px - (cmsFloat32Number) x0);
y0 = (int) _cmsQuickFloor(py); ry = (py - (cmsFloat32Number) y0);