Code

fix 198818
authorbuliabyak <buliabyak@users.sourceforge.net>
Wed, 5 Mar 2008 17:25:58 +0000 (17:25 +0000)
committerbuliabyak <buliabyak@users.sourceforge.net>
Wed, 5 Mar 2008 17:25:58 +0000 (17:25 +0000)
src/display/sp-canvas.cpp

index 88a4574907c2fba5a1d448b5877a3742cce0f5b2..b042f0d68ce96d76c581e65cde28df7d8d0b0734 100644 (file)
@@ -1747,7 +1747,8 @@ faster.
 The default for now is the strips mode.
 */
     if (bw < bh || bh < 2 * TILE_SIZE) {
-        int mid = (this_rect.x0 + this_rect.x1) / 2;
+        // to correctly calculate the mean of two ints, we need to sum them into a larger int type
+        int mid = ((long long) this_rect.x0 + (long long) this_rect.x1) / 2;
         // Make sure that mid lies on a tile boundary
         mid = (mid / TILE_SIZE) * TILE_SIZE;
 
@@ -1763,7 +1764,8 @@ The default for now is the strips mode.
                 && sp_canvas_paint_rect_internal(setup, lo);
         }
     } else {
-        int mid = (this_rect.y0 + this_rect.y1) / 2;
+        // to correctly calculate the mean of two ints, we need to sum them into a larger int type
+        int mid = ((long long) this_rect.y0 + (long long) this_rect.y1) / 2;
         // Make sure that mid lies on a tile boundary
         mid = (mid / TILE_SIZE) * TILE_SIZE;