Ignore:
Timestamp:
Jan 11, 2017, 10:14:11 PM (7 years ago)
Author:
chronos
Message:
  • Fixed: More Bitmap.ScanLine replaced by direct access to RAWImage data.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LocalPlayer/Term.pas

    r50 r52  
    506506  Sharpen = 80;
    507507type
    508   TLine = array [0 .. 99999, 0 .. 2] of Byte;
    509508  TBuffer = array [0 .. 99999, 0 .. 2] of integer;
    510509var
     
    512511    ydivider: integer;
    513512  resampled: ^TBuffer;
    514   line: ^TLine;
     513  PixelPtr: TPixelPointer;
    515514begin
    516515  nx := BigImp.width div xSizeBig * xSizeSmall;
     
    529528        if ydivider > ySizeSmall then
    530529          ydivider := ySizeSmall;
    531         line := BigImp.ScanLine[cut + iy * ySizeBig + y];
     530        PixelPtr.Init(BigImp, 0, cut + iy * ySizeBig + y);
    532531        for x := 0 to xSizeBig - 1 do
    533532        begin
     
    541540          for ch := 0 to 2 do
    542541          begin
    543             c := line[ix * xSizeBig + x, ch];
     542            PixelPtr.SetX(ix * xSizeBig + x);
     543            c := PixelPtr.Pixel^.Planes[ch];
    544544            inc(resampled[ir, ch], c * xdivider * ydivider);
    545545            if xdivider < xSizeSmall then
     
    558558
    559559  // sharpen resampled icons
    560   SmallImp.width := nx;
    561   SmallImp.height := ny;
     560  SmallImp.SetSize(nx, ny);
    562561  SmallImp.BeginUpdate;
    563   for y := 0 to ny - 1 do
    564   begin
    565     line := SmallImp.ScanLine[y];
     562  for y := 0 to ny - 1 do begin
     563    PixelPtr.Init(SmallImp, 0, y);
    566564    for x := 0 to nx - 1 do
    567       for ch := 0 to 2 do
    568       begin
     565      for ch := 0 to 2 do begin
    569566        sum := 0;
    570567        Cnt := 0;
     
    581578        sum := ((Cnt * Sharpen + 800) * resampled[x + nx * y, ch] - sum *
    582579          Sharpen) div (800 * xSizeBig * (ySizeBig - 2 * cut));
    583         if sum < 0 then
    584           sum := 0;
    585         if sum > 255 then
    586           sum := 255;
    587         line[x][ch] := sum;
     580        if sum < 0 then sum := 0;
     581        if sum > 255 then sum := 255;
     582        PixelPtr.SetX(x);
     583        PixelPtr.Pixel^.Planes[ch] := sum;
    588584      end;
    589585  end;
     
    40664062
    40674063procedure TMainScreen.MiniPaint;
    4068 type
    4069   TLine = array [0 .. 99999999, 0 .. 2] of Byte;
    40704064var
    40714065  uix, cix, x, y, Loc, i, hw, xm, cm, cmPolOcean, cmPolNone: integer;
    4072   PrevMiniLine, MiniLine: ^TLine;
     4066  PrevMiniPixel, MiniPixel: PPixel32;
    40734067begin
    40744068  cmPolOcean := GrExt[HGrSystem].Data.Canvas.Pixels[101, 67];
     
    40804074    FillRect(Rect(0, 0, Mini.width, Mini.height));
    40814075  end;
    4082   MiniLine := nil;
    40834076  Mini.BeginUpdate;
    40844077  for y := 0 to G.ly - 1 do
    40854078  begin
    4086     PrevMiniLine := MiniLine;
    4087     MiniLine := Mini.ScanLine[y];
    40884079    for x := 0 to G.lx - 1 do
    40894080      if MyMap[x + G.lx * y] and fTerrain <> fUNKNOWN then
     
    40934084        begin
    40944085          xm := ((x - xwMini) * 2 + i + y and 1 - hw + G.lx * 5) mod (G.lx * 2);
     4086          MiniPixel := GetBitmapPixelPtr(Mini, xm, y);
    40954087          cm := MiniColors[MyMap[Loc] and fTerrain, i];
    40964088          if ClientMode = cEditMap then
     
    41154107            end;
    41164108            cm := $808080 or cm shr 1; { increase brightness }
    4117             if PrevMiniLine <> nil then
    4118             begin // 2x2 city dot covers two scanlines
    4119               PrevMiniLine[xm, 0] := cm shr 16;
    4120               PrevMiniLine[xm, 1] := cm shr 8 and $FF;
    4121               PrevMiniLine[xm, 2] := cm and $FF;
     4109            if y > 0 then begin
     4110              // 2x2 city dot covers two scanlines
     4111              PrevMiniPixel := GetBitmapPixelPtr(Mini, xm, y - 1);
     4112              PrevMiniPixel^.B := cm shr 16;
     4113              PrevMiniPixel^.G := cm shr 8 and $FF;
     4114              PrevMiniPixel^.R := cm and $FF;
    41224115            end
    41234116          end
     
    41484141              cm := Tribe[MyRO.Territory[Loc]].Color;
    41494142          end;
    4150           MiniLine[xm, 0] := cm shr 16;
    4151           MiniLine[xm, 1] := cm shr 8 and $FF;
    4152           MiniLine[xm, 2] := cm and $FF;
     4143          MiniPixel^.B := cm shr 16;
     4144          MiniPixel^.G := cm shr 8 and $FF;
     4145          MiniPixel^.R := cm and $FF;
    41534146        end;
    41544147      end;
Note: See TracChangeset for help on using the changeset viewer.