hedgewars/uLand.pas
changeset 10018 bdf75f0350bd
parent 10016 59a6d65fcb60
child 10022 eb981a03de90
equal deleted inserted replaced
10016:59a6d65fcb60 10018:bdf75f0350bd
    58     if (width div 4096 >= 2) or (height div 2048 >= 2) then cMaxZoomLevel:= 0.5;
    58     if (width div 4096 >= 2) or (height div 2048 >= 2) then cMaxZoomLevel:= 0.5;
    59     cMinMaxZoomLevelDelta:= cMaxZoomLevel - cMinZoomLevel
    59     cMinMaxZoomLevelDelta:= cMaxZoomLevel - cMinZoomLevel
    60     end;
    60     end;
    61 end;
    61 end;
    62 
    62 
    63 { this will make invisible pixels that have a visible neighbor have the
       
    64   same color as their visible neighbor, so that bilinear filtering won't
       
    65   display a "wrongly" colored border when zoomed in }
       
    66 procedure PrettifyLandAlpha();
    63 procedure PrettifyLandAlpha();
    67 var
    64 begin
    68     x, y, lastx, lasty: Longword;
       
    69     lpi, cpi, bpi: boolean; // was last/current/bottom neighbor pixel invisible?
       
    70 begin
       
    71     lasty:= LAND_HEIGHT - 1;
       
    72     lastx:= LAND_WIDTH - 1;
       
    73     if (cReducedQuality and rqBlurryLand) <> 0 then
    65     if (cReducedQuality and rqBlurryLand) <> 0 then
    74         begin
    66         PrettifyAlpha2D(LandPixels, LAND_HEIGHT div 2, LAND_WIDTH div 2)
    75         lasty:= lasty div 2;
    67     else
    76         lastx:= lastx div 2;
    68         PrettifyAlpha2D(LandPixels, LAND_HEIGHT, LAND_WIDTH);
    77         end;
    69 end;
    78     for y:= 0 to lasty do
       
    79         for x:= 0 to lastx do
       
    80             begin
       
    81             // use first pixel in row as starting point
       
    82             //LandPixels[y, x]:= (LandPixels[y, x] and (BMask or GMask or AMask));
       
    83             if x = 0 then
       
    84                 lpi:= ((LandPixels[y, x] and AMask) = 0)
       
    85             else
       
    86                 begin
       
    87                 cpi:= ((LandPixels[y, x] and AMask) = 0);
       
    88                 if lpi <> cpi then
       
    89                     begin
       
    90                     // invisible pixels get colors from visible neighbors
       
    91                     if cpi then
       
    92                         begin
       
    93                         LandPixels[y, x]:= LandPixels[y, x-1] and not AMask;
       
    94                         // as this pixel is invisible and already colored correctly now, no point in further comparing it
       
    95                         lpi:= cpi;
       
    96                         continue;
       
    97                         end
       
    98                     else
       
    99                         LandPixels[y, x-1]:= LandPixels[y, x] and not AMask;
       
   100                     lpi:= cpi;
       
   101                     end;
       
   102                 end;
       
   103             // also check bottom neighbor, lpi is now current pixel info
       
   104             if y < lasty - 1 then
       
   105                 begin
       
   106                 bpi:= ((LandPixels[y+1, x] and AMask) = 0);
       
   107                 if cpi <> bpi then
       
   108                     begin
       
   109                     if cpi then
       
   110                         LandPixels[y, x]:= LandPixels[y+1, x] and not AMask
       
   111                     else
       
   112                         LandPixels[y+1, x]:= LandPixels[y, x] and not AMask;
       
   113                     end;
       
   114                 end
       
   115             end;
       
   116 end;
       
   117 
       
   118 
    70 
   119 procedure DrawBorderFromImage(Surface: PSDL_Surface);
    71 procedure DrawBorderFromImage(Surface: PSDL_Surface);
   120 var tmpsurf: PSDL_Surface;
    72 var tmpsurf: PSDL_Surface;
   121     r, rr: TSDL_Rect;
    73     r, rr: TSDL_Rect;
   122     x, yd, yu: LongInt;
    74     x, yd, yu: LongInt;