From 63de99a5b3fa9212c5dfd7020fd6bce6f40af3b6 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Fri, 31 Jan 2025 18:54:32 +0000 Subject: [PATCH] fix invertlut in some cases If the measurements filled the entire x range, we were not writing the final value. For example: ``` 2 2 0 0 1 1 ``` ``` $ vips invertlut linear.mat x2.v $ vips getpoint x2.v 255 0 -nan ``` With this PR you get 1, as expected. --- ChangeLog | 1 + libvips/create/invertlut.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index ae0098ca47..9fa1247943 100644 --- a/ChangeLog +++ b/ChangeLog @@ -19,6 +19,7 @@ - fill_nearest: fix a leak - colour: use suggested rendering intent as fallback [kleisauke] - morph: fix Orc path with large masks [kleisauke] +- invertlut: fix final value in some cases 10/10/24 8.16.0 diff --git a/libvips/create/invertlut.c b/libvips/create/invertlut.c index ff24aab7eb..02a89baa4c 100644 --- a/libvips/create/invertlut.c +++ b/libvips/create/invertlut.c @@ -212,7 +212,7 @@ vips_invertlut_build_create(VipsInvertlut *lut) /* Interpolate the data sections. */ - for (k = first; k < last; k++) { + for (k = first; k <= last; k++) { /* Where we're at in the [0,1] range. */ double ki = (double) k / (lut->size - 1);