Ignore:
Timestamp:
Jan 14, 2017, 8:42:46 PM (8 years ago)
Author:
chronos
Message:
  • Fixed: Removed last occurences of Bitmap.ScanLine usage and adjusted to support Linux 32-bit RAW image format.
  • Modified: Simplified LoadLocalizedGraphicFile function as it do same thing as LoadGraphicFile just with localized directory.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LocalPlayer/IsoEngine.pas

    r58 r68  
    104104
    105105function ApplyTileSize(xxtNew, yytNew: integer): boolean;
    106 type
    107   TLine = array [0 .. INFIN, 0 .. 2] of Byte;
    108106var
    109107  i, x, y, xSrc, ySrc, HGrTerrainNew, HGrCitiesNew, age, size: integer;
    110108  LandMore, OceanMore, DitherMask, Mask24: TBitmap;
    111   MaskLine: array [0 .. 32 * 3 - 1] of ^TLine; // 32 = assumed maximum for yyt
     109  MaskLine: array [0 .. 32 * 3 - 1] of TPixelPointer; // 32 = assumed maximum for yyt
    112110  Border: boolean;
    113111begin
     
    346344  begin
    347345    for i := 0 to yyt * 3 - 1 do
    348       MaskLine[i] := Mask24.ScanLine[1 + ySrc * (yyt * 3 + 1) + i];
     346      MaskLine[i].Init(Mask24, 0, 1 + ySrc * (yyt * 3 + 1) + i);
    349347    for xSrc := 0 to 9 - 1 do
    350348    begin
     
    353351      repeat
    354352        Border := true;
    355         for y := 0 to yyt * 3 - 1 do
    356           if MaskLine[y]^[1 + xSrc * (xxt * 2 + 1) + TSpriteSize[i].Left, 0] = 0
    357           then
    358             Border := false;
    359         if Border then
    360           inc(TSpriteSize[i].Left);
     353        for y := 0 to yyt * 3 - 1 do begin
     354          MaskLine[y].SetX(1 + xSrc * (xxt * 2 + 1) + TSpriteSize[i].Left);
     355          if MaskLine[y].Pixel^.B = 0 then Border := false;
     356        end;
     357        if Border then Inc(TSpriteSize[i].Left);
    361358      until not Border or (TSpriteSize[i].Left = xxt * 2 - 1);
    362359      TSpriteSize[i].Top := 0;
    363360      repeat
    364361        Border := true;
    365         for x := 0 to xxt * 2 - 1 do
    366           if MaskLine[TSpriteSize[i].Top]^[1 + xSrc * (xxt * 2 + 1) + x, 0] = 0
    367           then
    368             Border := false;
    369         if Border then
    370           inc(TSpriteSize[i].Top);
     362        for x := 0 to xxt * 2 - 1 do begin
     363          MaskLine[TSpriteSize[i].Top].SetX(1 + xSrc * (xxt * 2 + 1) + x);
     364          if MaskLine[TSpriteSize[i].Top].Pixel^.B = 0 then Border := false;
     365        end;
     366        if Border then inc(TSpriteSize[i].Top);
    371367      until not Border or (TSpriteSize[i].Top = yyt * 3 - 1);
    372368      TSpriteSize[i].Right := xxt * 2;
    373369      repeat
    374370        Border := true;
    375         for y := 0 to yyt * 3 - 1 do
    376           if MaskLine[y]^[xSrc * (xxt * 2 + 1) + TSpriteSize[i].Right, 0] = 0
    377           then
    378             Border := false;
    379         if Border then
    380           dec(TSpriteSize[i].Right);
     371        for y := 0 to yyt * 3 - 1 do begin
     372          MaskLine[y].SetX(xSrc * (xxt * 2 + 1) + TSpriteSize[i].Right);
     373          if MaskLine[y].Pixel^.B = 0 then Border := false;
     374        end;
     375        if Border then Dec(TSpriteSize[i].Right);
    381376      until not Border or (TSpriteSize[i].Right = TSpriteSize[i].Left);
    382377      TSpriteSize[i].Bottom := yyt * 3;
    383378      repeat
    384379        Border := true;
    385         for x := 0 to xxt * 2 - 1 do
    386           if MaskLine[TSpriteSize[i].Bottom - 1]^[1 + xSrc * (xxt * 2 + 1) + x,
    387             0] = 0 then
    388             Border := false;
    389         if Border then
    390           dec(TSpriteSize[i].Bottom);
     380        for x := 0 to xxt * 2 - 1 do begin
     381          MaskLine[TSpriteSize[i].Bottom - 1].SetX(1 + xSrc * (xxt * 2 + 1) + x);
     382          if MaskLine[TSpriteSize[i].Bottom - 1].Pixel^.B = 0 then Border := false;
     383        end;
     384        if Border then Dec(TSpriteSize[i].Bottom);
    391385      until not Border or (TSpriteSize[i].Bottom = TSpriteSize[i].Top);
    392386    end
     
    930924procedure TIsoMap.PaintTileObjects(x, y, Loc, CityLoc, CityOwner: integer;
    931925  UseBlink: boolean);
    932 type
    933   TLine = array [0 .. 9 * 65, 0 .. 2] of Byte;
    934926var
    935927  p1, p2, uix, cix, dy, Loc1, Tile, Multi, Destination: integer;
     
    12991291
    13001292  procedure ShadeOutside(x0, y0, x1, y1, xm, ym: integer);
     1293
     1294    procedure MakeDark(Line: PPixelPointer; Length: Integer);
     1295    var
     1296      I: Integer;
     1297    begin
     1298      for I := 0 to Length - 1 do begin
     1299        Line^.Pixel^.B := (Line^.Pixel^.B shr 1) and $7f;
     1300        Line^.Pixel^.G := (Line^.Pixel^.G shr 1) and $7f;
     1301        Line^.Pixel^.R := (Line^.Pixel^.R shr 1) and $7f;
     1302        Line^.NextPixel;
     1303      end;
     1304    end;
     1305
    13011306  const
    13021307    rShade = 3.75;
    1303 
    1304     procedure MakeDark(Line: pointer; length: integer);
    1305     type
    1306       TCardArray = array [0 .. 9999] of Cardinal;
    1307       PCardArray = ^TCardArray;
    1308       TByteArray = array [0 .. 9999] of Byte;
    1309       PByteArray = ^TByteArray;
    1310     var
    1311       i, rest: integer;
    1312     begin
    1313       for i := length * 3 div 4 - 1 downto 0 do
    1314         PCardArray(Line)[i] := PCardArray(Line)[i] shr 1 and $7F7F7F7F;
    1315       rest := (length * 3 div 4) * 4;
    1316       for i := length * 3 mod 4 - 1 downto 0 do
    1317         PByteArray(Line)[rest + i] := PByteArray(Line)[rest + i] shr 1 and $7F;
    1318     end;
    1319 
    1320   type
    1321     TLine = array [0 .. 99999, 0 .. 2] of Byte;
    13221308  var
    13231309    y, wBright: integer;
    13241310    y_n, w_n: single;
    1325     Line: ^TLine;
     1311    Line: TPixelPointer;
    13261312  begin
    13271313    FOutput.BeginUpdate;
    1328     for y := y0 to y1 - 1 do
    1329     begin
    1330       Line := FOutput.ScanLine[y];
     1314    for y := y0 to y1 - 1 do begin
     1315      Line.Init(FOutput, 0, y);
    13311316      y_n := (y - ym) / yyt;
    1332       if abs(y_n) < rShade then
    1333       begin
     1317      if abs(y_n) < rShade then begin
     1318        // Darken left and right parts of elipsis
    13341319        w_n := sqrt(sqr(rShade) - sqr(y_n));
    13351320        wBright := trunc(w_n * xxt + 0.5);
    1336         MakeDark(@Line[x0], xm - x0 - wBright);
    1337         MakeDark(@Line[xm + wBright], x1 - xm - wBright);
    1338       end
    1339       else
    1340         MakeDark(@Line[x0], x1 - x0);
     1321        Line.SetX(x0);
     1322        MakeDark(@Line, xm - x0 - wBright);
     1323        Line.SetX(xm + wBright);
     1324        MakeDark(@Line, x1 - xm - wBright);
     1325      end else begin
     1326        // Darken entire line
     1327        Line.SetX(x0);
     1328        MakeDark(@Line, x1 - x0);
     1329      end;
    13411330    end;
    13421331    FOutput.EndUpdate;
Note: See TracChangeset for help on using the changeset viewer.