fix despeckle mutilating blurry land
authorsheepluva
Sun, 19 Jan 2014 22:39:06 +0100
changeset 10023 fa9674c94c4f
parent 10022 eb981a03de90
child 10024 7d21f52f0452
fix despeckle mutilating blurry land
hedgewars/uLandGraphics.pas
--- a/hedgewars/uLandGraphics.pas	Mon Jan 20 00:25:40 2014 +0400
+++ b/hedgewars/uLandGraphics.pas	Sun Jan 19 22:39:06 2014 +0100
@@ -679,6 +679,7 @@
 function Despeckle(X, Y: LongInt): boolean;
 var nx, ny, i, j, c, xx, yy: LongInt;
     pixelsweep: boolean;
+
 begin
     Despeckle:= true;
 
@@ -709,11 +710,14 @@
                         begin
                             if ((cReducedQuality and rqBlurryLand) <> 0) then
                             begin
-                                nx:= nx div 2;
-                                ny:= ny div 2
-                            end;
-                            if LandPixels[ny, nx] <> 0 then
-                                inc(c);
+                                ny:= Y div 2 + i;
+                                nx:= X div 2 + j;
+                                if ((ny and (LAND_HEIGHT_MASK div 2)) = 0) and ((nx and (LAND_WIDTH_MASK div 2)) = 0) then
+                                    if LandPixels[ny, nx] <> 0 then
+                                        inc(c);
+                            end
+                            else if LandPixels[ny, nx] <> 0 then
+                                    inc(c);
                         end
                     else if Land[ny, nx] > 255 then
                         inc(c);