Ignore:
Timestamp:
Apr 16, 2024, 11:43:51 AM (4 weeks ago)
Author:
chronos
Message:
  • Modified: Optimized scaled bitmap drawing.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Packages/DpiControls/Dpi.PixelPointer.pas

    r538 r539  
    3434    function GetPixelB: Byte; inline;
    3535    function GetPixelG: Byte; inline;
    36     function GetPixelPlane(Index: Byte): Byte;
     36    function GetPixelPlane(Index: Byte): Byte; inline;
    3737    function GetPixelR: Byte; inline;
    3838    function GetPixelA: Byte; inline;
    3939    function GetPixelPlanes: TColor32Planes;
    40     function GetPixelRGB: Cardinal;
     40    function GetPixelRGB: Cardinal; inline;
    4141    procedure SetPixelARGB(Value: TColor32); inline;
    4242    procedure SetPixelB(Value: Byte); inline;
    4343    procedure SetPixelG(Value: Byte); inline;
    44     procedure SetPixelPlane(Index: Byte; AValue: Byte);
     44    procedure SetPixelPlane(Index: Byte; AValue: Byte); inline;
    4545    procedure SetPixelR(Value: Byte); inline;
    4646    procedure SetPixelA(Value: Byte); inline;
    47     procedure SetPixelRGB(Value: Cardinal);
     47    procedure SetPixelRGB(Value: Cardinal); inline;
    4848  public
    4949    Base: PPixel32;
     
    6363    procedure SetX(X: Integer); inline; // Set horizontal pixel position relative to base
    6464    procedure CheckRange; inline; // Check if current pixel position is not out of range
     65    function PosValid: Boolean;
    6566    class function Create(Bitmap: TRasterImage; BaseX: Integer = 0; BaseY: Integer = 0): TPixelPointer; static;
    6667    property PixelARGB: TColor32 read GetPixelARGB write SetPixelARGB;
     
    105106procedure TPixel32.SetRGB(AValue: Cardinal);
    106107begin
    107   R := (AValue shr 16) and $ff;
    108   G := (AValue shr 8) and $ff;
    109   B := (AValue shr 0) and $ff;
     108  ARGB := (ARGB and $ff000000) or (AValue and $ffffff);
    110109end;
    111110
     
    148147{$IFOPT R+}
    149148var
    150   B: Integer;
    151149  X: Integer;
    152150  Y: Integer;
     
    156154  if (PByte(Pixel) < PByte(Data)) or
    157155    (PByte(Pixel) >= PByte(Data) + Height * BytesPerLine) then begin
    158     B := PByte(Pixel) - PByte(Data);
    159     Y := Floor(B / BytesPerLine);
    160     X := B - Y * BytesPerLine;
     156    X := PByte(Pixel) - PByte(Data);
     157    Y := Floor(X / BytesPerLine);
     158    X := X - Y * BytesPerLine;
    161159    X := Floor(X / BytesPerPixel);
    162160    raise Exception.Create(Format(SOutOfRange, [X, Y, Width, Height]));
    163161  end;
    164162  {$ENDIF}
     163end;
     164
     165function TPixelPointer.PosValid: Boolean;
     166begin
     167  Result := not ((PByte(Pixel) < PByte(Data)) or
     168    (PByte(Pixel) >= PByte(Data) + Height * BytesPerLine));
    165169end;
    166170
Note: See TracChangeset for help on using the changeset viewer.