From 2c969b70a5670bb976a767edeecd216da7a35047 Mon Sep 17 00:00:00 2001 From: castano Date: Tue, 7 Sep 2010 18:08:53 +0000 Subject: [PATCH] Fix mirror sampling in trunk. Fixes issue 135. --- src/nvimage/FloatImage.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/nvimage/FloatImage.cpp b/src/nvimage/FloatImage.cpp index f2bf44f..9ef4099 100644 --- a/src/nvimage/FloatImage.cpp +++ b/src/nvimage/FloatImage.cpp @@ -21,10 +21,13 @@ namespace { static int mirror(int x, int w) { + if (w == 1) return 0; + x = abs(x); while (x >= w) { - x = 2 * w - x - 2; + x = abs(w + w - x - 2); } + return x; } }