Changeset 62 for trunk/ScreenTools.pas


Ignore:
Timestamp:
Jan 13, 2017, 7:45:16 PM (7 years ago)
Author:
chronos
Message:
  • Fixed: Replaced ScanLine access be linux supported pixel access.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ScreenTools.pas

    r60 r62  
    3838    BytesPerPixel: Integer;
    3939    BytesPerLine: Integer;
    40     procedure NextLine;
    41     procedure NextPixel;
    42     procedure SetXY(X, Y: Integer);
    43     procedure SetX(X: Integer);
    44     procedure Init(Bitmap: TBitmap; X: Integer = 0; Y: Integer = 0);
     40    procedure NextLine; inline;
     41    procedure NextPixel; inline;
     42    procedure SetXY(X, Y: Integer); inline;
     43    procedure SetX(X: Integer); inline;
     44    procedure Init(Bitmap: TBitmap; X: Integer = 0; Y: Integer = 0); inline;
    4545  end;
    4646
     
    624624
    625625procedure MakeBlue(dst: TBitmap; x, y, w, h: integer);
    626 type
    627   TLine = array [0 .. 99999, 0 .. 2] of Byte;
    628   PLine = ^TLine;
    629 
    630   procedure BlueLine(line: PLine; Length: integer);
    631   var
    632     i: integer;
    633   begin
    634     for i := 0 to Length - 1 do
    635     begin
    636       line[i, 0] := line[i, 0] div 2;
    637       line[i, 1] := line[i, 1] div 2;
    638       line[i, 2] := line[i, 2] div 2;
    639     end
    640   end;
    641 
    642 var
    643   i: integer;
    644 begin
    645   dst.BeginUpdate;
    646   for i := 0 to h - 1 do
    647     BlueLine(@(PLine(dst.ScanLine[y + i])[x]), w);
    648   dst.EndUpdate;
     626var
     627  XX, YY: Integer;
     628  PixelPtr: TPixelPointer;
     629begin
     630  Dst.BeginUpdate;
     631  PixelPtr.Init(Dst, 0, 0);
     632  for yy := 0 to h - 1 do begin
     633    for xx := 0 to w - 1 do begin
     634      PixelPtr.Pixel^.B := PixelPtr.Pixel^.B div 2;
     635      PixelPtr.Pixel^.G := PixelPtr.Pixel^.G div 2;
     636      PixelPtr.Pixel^.R := PixelPtr.Pixel^.R div 2;
     637      PixelPtr.NextPixel;
     638    end;
     639    PixelPtr.NextLine;
     640  end;
     641  Dst.EndUpdate;
    649642end;
    650643
     
    916909
    917910procedure GlowFrame(dst: TBitmap; x0, y0, Width, Height: integer; cl: TColor);
    918 type
    919   TLine = array [0 .. 649, 0 .. 2] of Byte;
    920911var
    921912  x, y, ch, r: integer;
    922   DstLine: ^TLine;
     913  DstPtr: TPixelPointer;
    923914begin
    924915  dst.BeginUpdate;
    925916  for y := -GlowRange + 1 to Height - 1 + GlowRange - 1 do
    926917  begin
    927     DstLine := dst.ScanLine[y0 + y];
    928918    for x := -GlowRange + 1 to Width - 1 + GlowRange - 1 do
    929919    begin
     920      DstPtr.Init(dst, x0 + x, y0 + y);
    930921      if x < 0 then
    931922        if y < 0 then
     
    952943      if r < GlowRange then
    953944        for ch := 0 to 2 do
    954           DstLine[x0 + x][2 - ch] :=
    955             (DstLine[x0 + x][2 - ch] * (r - 1) + (cl shr (8 * ch) and $FF) *
     945          DstPtr.Pixel^.Planes[2 - ch] :=
     946            (DstPtr.Pixel^.Planes[2 - ch] * (r - 1) + (cl shr (8 * ch) and $FF) *
    956947            (GlowRange - r)) div (GlowRange - 1);
    957948    end;
Note: See TracChangeset for help on using the changeset viewer.