Changeset 539 for trunk/Packages/Common


Ignore:
Timestamp:
Apr 16, 2024, 11:43:51 AM (7 months ago)
Author:
chronos
Message:
  • Modified: Optimized scaled bitmap drawing.
Location:
trunk/Packages/Common
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Packages/Common/Languages/PixelPointer.pot

    r506 r539  
    44#: pixelpointer.soutofrange
    55#, object-pascal-format
    6 msgid "Pixel pointer out of range [X: %d. Y: %d]"
     6msgid "Pixel pointer out of range [X: %d, Y: %d, Width: %d, Height: %d]"
    77msgstr ""
    88
  • trunk/Packages/Common/PixelPointer.pas

    r506 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;
     
    9394
    9495resourcestring
    95   SOutOfRange = 'Pixel pointer out of range [X: %d. Y: %d]';
     96  SOutOfRange = 'Pixel pointer out of range [X: %d, Y: %d, Width: %d, Height: %d]';
    9697  SWrongBitmapSize = 'Wrong bitmap size [width: %d, height: %d]';
    9798
     
    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
     
    159158    X := X - Y * BytesPerLine;
    160159    X := Floor(X / BytesPerPixel);
    161     raise Exception.Create(Format(SOutOfRange, [X, Y]));
     160    raise Exception.Create(Format(SOutOfRange, [X, Y, Width, Height]));
    162161  end;
    163162  {$ENDIF}
     163end;
     164
     165function TPixelPointer.PosValid: Boolean;
     166begin
     167  Result := not ((PByte(Pixel) < PByte(Data)) or
     168    (PByte(Pixel) >= PByte(Data) + Height * BytesPerLine));
    164169end;
    165170
Note: See TracChangeset for help on using the changeset viewer.