diff --git a/src/display/nr-filter-displacement-map.cpp b/src/display/nr-filter-displacement-map.cpp
index d2b1c2a0bdb3093503a569f8feec815ce00aee4f..4de5e658cd3909a111ca661f1eeaaf77894abe0c 100644 (file)
* feDisplacementMap filter primitive renderer
*
* Authors:
- * Felipe CorrĂȘa da Silva Sanches <felipe.sanches@gmail.com>
+ * Felipe CorrĂȘa da Silva Sanches <juca@members.fsf.org>
*
* Copyright (C) 2007 authors
*
template<bool PREMULTIPLIED>
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<<sfl;
unsigned int const sf2h = 1u<<(2u*sfl-1);
int xi = (int)floor(x), yi = (int)floor(y);
- unsigned int xf = static_cast<unsigned int>(floor(sf*(x-xi)+.5)), yf = static_cast<unsigned int>(floor(sf*(y-yi)+.5));
+ unsigned int xf = static_cast<unsigned int>(round(sf * (x - xi))),
+ yf = static_cast<unsigned int>(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);
@@ -121,8 +124,8 @@ static void performDisplacement(NRPixBlock const* texture, NRPixBlock const* map
if (!Xneedsdemul) scalex /= 255.0;
if (!Yneedsdemul) scaley /= 255.0;
- for (int xout=out->area.x0; xout < out->area.x1; xout++){
- for (int yout=out->area.y0; yout < out->area.y1; yout++){
+ for (int yout=out->area.y0; yout < out->area.y1; yout++){
+ for (int xout=out->area.x0; xout < out->area.x1; xout++){
int xmap = xout;
int ymap = yout;