From a24a1c8e4efc32eaebe7b6111483b75a4af2a4b9 Mon Sep 17 00:00:00 2001 From: Niels Martin Hansen Date: Sat, 29 Dec 2007 22:28:41 +0000 Subject: [PATCH] Fix to "mirror" edge condition class Originally committed to SVN as r1657. --- OverLua/image.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/OverLua/image.h b/OverLua/image.h index 9446d5c66..b2723909d 100644 --- a/OverLua/image.h +++ b/OverLua/image.h @@ -35,6 +35,7 @@ #include #include #include +#include // Forward @@ -631,8 +632,8 @@ namespace EdgeCondition { while (y < 0) y += img.height*2; while (x >= img.width*2) x -= img.width*2; while (y >= img.height*2) y -= img.height*2; - if (x >= img.width) x = img.width - x; - if (y >= img.height) y = img.height - y; + if (x >= img.width) x = img.width*2 - x; + if (y >= img.height) y = img.height*2 - y; return img.Pixel(x,y); } }; @@ -647,6 +648,9 @@ inline PixFmt GetPixelBilinear(BaseImage &img, double x, double y) PixFmt res; double xpct = x - floor(x), ypct = y - floor(y); + if (xpct == 0 && ypct == 0) + return EdgeCond::get(img, (int)x, (int)y); + const PixFmt &src11 = EdgeCond::get(img, (int)x, (int)y); const PixFmt &src12 = EdgeCond::get(img, (int)x, 1+(int)y); const PixFmt &src21 = EdgeCond::get(img, 1+(int)x, (int)y);