panolib.c: Fixed argument-checking in the bilinear interpolation.
[libopano.git] / src / panolib.c
index 2686059..6d503d6 100644 (file)
@@ -91,16 +91,16 @@ static int copy_pixel (ui_image_t *dest, const ui_image_t *src,
                int i;
 
                x_src_left = (int) x_src_fp;
-               x_src_right = x_src_left + 1;
+               x_src_right = (x_src_left + 1) % src->width;
+
                y_src_top  = (int) y_src_fp;
                y_src_bottom = y_src_top + 1;
+               if (y_src_bottom >= src->height)
+                       y_src_bottom = src->height - 1;
 
                x_right_frac = x_src_fp - x_src_left;
                y_bottom_frac = y_src_fp - y_src_top;
 
-               assert (x_src_right < src->width);
-               assert (y_src_bottom < src->height);
-
                assert ((x_right_frac >= 0.0) && (x_right_frac <= 1.0));
                assert ((y_bottom_frac >= 0.0) && (y_bottom_frac <= 1.0));