From 50beb2f2d201ea5d5fcaf5e38b202d1e677f1a85 Mon Sep 17 00:00:00 2001 From: kiirala Date: Sun, 5 Apr 2009 15:49:17 +0000 Subject: [PATCH] Fixed offset in interpolation in nr-filter-displacement-map --- src/display/nr-filter-displacement-map.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/display/nr-filter-displacement-map.cpp b/src/display/nr-filter-displacement-map.cpp index d2b1c2a0b..3c59d70e7 100644 --- a/src/display/nr-filter-displacement-map.cpp +++ b/src/display/nr-filter-displacement-map.cpp @@ -9,6 +9,12 @@ * 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" @@ -53,12 +59,13 @@ static pixel_t interpolatePixels(NRPixBlock const* pb, double x, double y) { unsigned int const sfl = 8u; unsigned int const sf = 1u<(floor(sf*(x-xi)+.5)), yf = static_cast(floor(sf*(y-yi)+.5)); - 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); + int xi = (int)round(x), yi = (int)round(y); + unsigned int xf = static_cast(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); /* It's a good idea to interpolate premultiplied colors: * -- 2.30.2