From 17f63b09c2f8746e1b65d470567eac2a18d7b2ca Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Fri, 16 Sep 2011 16:32:58 +0200 Subject: Correct the formula of the displacement map so that zero alpha value means maximum negative displacement rather than zero displacement. Fixes artifacts in filters. Fixed bugs: - https://launchpad.net/bugs/849064 (bzr r10632) --- src/display/nr-filter-displacement-map.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/display/nr-filter-displacement-map.cpp b/src/display/nr-filter-displacement-map.cpp index 01c644bc1..9b44c2302 100644 --- a/src/display/nr-filter-displacement-map.cpp +++ b/src/display/nr-filter-displacement-map.cpp @@ -43,15 +43,16 @@ struct Displace { guint32 a = (mappx & 0xff000000) >> 24; guint32 xpx = 0, ypx = 0; double xtex = x, ytex = y; + + guint32 xshift = _xch * 8, yshift = _ych * 8; + xpx = (mappx & (0xff << xshift)) >> xshift; + ypx = (mappx & (0xff << yshift)) >> yshift; if (a) { - guint32 xshift = _xch * 8, yshift = _ych * 8; - xpx = (mappx & (0xff << xshift)) >> xshift; - ypx = (mappx & (0xff << yshift)) >> yshift; if (_xch != 3) xpx = unpremul_alpha(xpx, a); if (_ych != 3) ypx = unpremul_alpha(ypx, a); - xtex += _scalex * (xpx - 127.5); - ytex += _scaley * (ypx - 127.5); } + xtex += _scalex * (xpx - 127.5); + ytex += _scaley * (ypx - 127.5); if (xtex >= 0 && xtex < (_texture._w - 1) && ytex >= 0 && ytex < (_texture._h - 1)) -- cgit v1.2.3