From 2065eedb53dc1b14abfa4c7cdd70be141a5012ac Mon Sep 17 00:00:00 2001 From: jaspervdg Date: Sun, 5 Apr 2009 19:46:56 +0000 Subject: [PATCH] Reverts "fix" of offset in the displacement map code (and adds a comment to prevent another misunderstanding). --- src/display/nr-filter-displacement-map.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/display/nr-filter-displacement-map.cpp b/src/display/nr-filter-displacement-map.cpp index 3c59d70e7..4cd0f5160 100644 --- a/src/display/nr-filter-displacement-map.cpp +++ b/src/display/nr-filter-displacement-map.cpp @@ -9,12 +9,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include -#if defined (SOLARIS) && (SOLARIS == 8) -#include "round.h" -using Inkscape::round; -#endif - #include "display/nr-filter-displacement-map.h" #include "display/nr-filter-types.h" #include "display/nr-filter-units.h" @@ -56,16 +50,18 @@ static inline pixel_t pixelValue(NRPixBlock const* pb, int x, int y) { template static pixel_t interpolatePixels(NRPixBlock const* pb, double x, double y) { + // NOTE: The values of x and y are shifted by -0.5 (the "true" values would be x+0.5 and y+0.5). + // This is done because otherwise the pixel values first have to be shifted by +0.5 and then by -0.5 again... unsigned int const sfl = 8u; unsigned int const sf = 1u<(round(sf * (x - (xi - 0.5)))), - yf = static_cast(round(sf * (y - (yi - 0.5)))); - pixel_t p00 = pixelValue(pb, xi-1, yi-1); - pixel_t p01 = pixelValue(pb, xi-0, yi-1); - pixel_t p10 = pixelValue(pb, xi-1, yi-0); - pixel_t p11 = pixelValue(pb, xi-0, yi-0); + int xi = (int)floor(x), yi = (int)floor(y); + unsigned int xf = static_cast(round(sf * (x - xi))), + yf = static_cast(round(sf * (y - yi))); + pixel_t p00 = pixelValue(pb, xi+0, yi+0); + pixel_t p01 = pixelValue(pb, xi+1, yi+0); + pixel_t p10 = pixelValue(pb, xi+0, yi+1); + pixel_t p11 = pixelValue(pb, xi+1, yi+1); /* It's a good idea to interpolate premultiplied colors: * -- 2.30.2