Changeset 72 for trunk/Start.pas


Ignore:
Timestamp:
Jan 15, 2017, 11:47:01 AM (8 years ago)
Author:
chronos
Message:
  • Modified: Unified direct pixel access using TPixelPointer.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Start.pas

    r64 r72  
    822822var
    823823  x, y: integer;
    824   PicturePixel: PPixel32;
     824  PicturePixel: TPixelPointer;
    825825begin
    826826  SetMainTextureByAge(-1);
     
    830830  Fill(EmptyPicture.Canvas, 0, 0, 64, 64, (wMaintexture - 64) div 2,
    831831    (hMaintexture - 64) div 2);
    832   for y := 0 to 63 do
    833   begin // darken texture for empty slot
    834     for x := 0 to 64 - 1 do
    835     begin
    836       PicturePixel := GetBitmapPixelPtr(EmptyPicture, x, y);
    837       PicturePixel^.B := Max(PicturePixel^.B - 28, 0);
    838       PicturePixel^.G := Max(PicturePixel^.G - 28, 0);
    839       PicturePixel^.R := Max(PicturePixel^.R - 28, 0);
    840     end
     832  // darken texture for empty slot
     833  PicturePixel.Init(EmptyPicture);
     834  for y := 0 to 63 do begin
     835    for x := 0 to 64 - 1 do begin
     836      PicturePixel.Pixel^.B := Max(PicturePixel.Pixel^.B - 28, 0);
     837      PicturePixel.Pixel^.G := Max(PicturePixel.Pixel^.G - 28, 0);
     838      PicturePixel.Pixel^.R := Max(PicturePixel.Pixel^.R - 28, 0);
     839      PicturePixel.NextPixel;
     840    end;
     841    PicturePixel.NextLine;
    841842  end;
    842843  EmptyPicture.EndUpdate;
     
    10011002  var
    10021003    i, x, y, xm, cm: integer;
    1003     MiniPixel: PPixel32;
     1004    MiniPixel: TPixelPointer;
    10041005    Map: ^TTileList;
    10051006  begin
     
    10111012    Mini.SetSize(MiniWidth * 2, MiniHeight);
    10121013    Mini.BeginUpdate;
     1014    MiniPixel.Init(Mini);
    10131015    for y := 0 to MiniHeight - 1 do begin
    10141016      for x := 0 to MiniWidth - 1 do begin
    10151017        for i := 0 to 1 do begin
    10161018          xm := (x * 2 + i + y and 1) mod (MiniWidth * 2);
    1017           MiniPixel := GetBitmapPixelPtr(Mini, xm, y);
     1019          MiniPixel.SetX(xm);
    10181020          cm := MiniColors
    10191021            [Map[x * lxmax div MiniWidth + lxmax *
    10201022            ((y * (lymax - 1) + MiniHeight div 2) div (MiniHeight - 1))] and
    10211023            fTerrain, i];
    1022           MiniPixel^.B := ((cm shr 16) and $FF) * Brightness div 3;
    1023           MiniPixel^.G := ((cm shr 8) and $FF) * Brightness div 3;
    1024           MiniPixel^.R := ((cm shr 0) and $FF) * Brightness div 3;
     1024          MiniPixel.Pixel^.B := ((cm shr 16) and $FF) * Brightness div 3;
     1025          MiniPixel.Pixel^.G := ((cm shr 8) and $FF) * Brightness div 3;
     1026          MiniPixel.Pixel^.R := ((cm shr 0) and $FF) * Brightness div 3;
    10251027        end;
    10261028      end;
     1029      MiniPixel.NextLine;
    10271030    end;
    10281031    Mini.EndUpdate;
     
    10351038  var
    10361039    i, x, y, xm, cm, Tile, OwnColor, EnemyColor: integer;
    1037     MiniPixel, PrevMiniPixel: PPixel32;
     1040    MiniPixel, PrevMiniPixel: TPixelPointer;
    10381041  begin
    10391042    OwnColor := GrExt[HGrSystem].Data.Canvas.Pixels[95, 67];
     
    10451048    begin
    10461049      Mini.BeginUpdate;
     1050      MiniPixel.Init(Mini);
     1051      PrevMiniPixel.Init(Mini, 0, -1);
    10471052      for y := 0 to MiniHeight - 1 do begin
    10481053        for x := 0 to MiniWidth - 1 do begin
    10491054          for i := 0 to 1 do begin
    10501055            xm := (x * 2 + i + y and 1) mod (MiniWidth * 2);
    1051             MiniPixel := GetBitmapPixelPtr(Mini, xm, y);
     1056            MiniPixel.SetX(xm);
    10521057            Tile := SaveMap[x + MiniWidth * y];
    10531058            if Tile and fTerrain = fUNKNOWN then
     
    10611066              if y > 0 then begin
    10621067                // 2x2 city dot covers two lines
    1063                 PrevMiniPixel := GetBitmapPixelPtr(Mini, xm, y - 1);
    1064                 PrevMiniPixel^.B := cm shr 16;
    1065                 PrevMiniPixel^.G:= cm shr 8 and $FF;
    1066                 PrevMiniPixel^.R := cm and $FF;
     1068                PrevMiniPixel.SetX(xm);
     1069                PrevMiniPixel.Pixel^.B := cm shr 16;
     1070                PrevMiniPixel.Pixel^.G:= cm shr 8 and $FF;
     1071                PrevMiniPixel.Pixel^.R := cm and $FF;
    10671072              end
    10681073            end
     
    10741079            else
    10751080              cm := MiniColors[Tile and fTerrain, i];
    1076             MiniPixel^.B := cm shr 16;
    1077             MiniPixel^.G:= cm shr 8 and $FF;
    1078             MiniPixel^.R := cm and $FF;
     1081            MiniPixel.Pixel^.B := cm shr 16;
     1082            MiniPixel.Pixel^.G:= cm shr 8 and $FF;
     1083            MiniPixel.Pixel^.R := cm and $FF;
    10791084          end;
    10801085        end;
Note: See TracChangeset for help on using the changeset viewer.