Ignore:
Timestamp:
Apr 16, 2024, 10:57:39 AM (4 weeks ago)
Author:
chronos
Message:
  • Fixed: Map drawing in case of fractional scaling.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Packages/DpiControls/NativePixelPointer.pas

    r506 r538  
    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
     
    159160    X := X - Y * BytesPerLine;
    160161    X := Floor(X / BytesPerPixel);
    161     raise Exception.Create(Format(SOutOfRange, [X, Y]));
     162    raise Exception.Create(Format(SOutOfRange, [X, Y, Width, Height]));
    162163  end;
    163164  {$ENDIF}
     165end;
     166
     167function TPixelPointer.PosValid: Boolean;
     168begin
     169  Result := not ((PByte(Pixel) < PByte(Data)) or
     170    (PByte(Pixel) >= PByte(Data) + Height * BytesPerLine));
    164171end;
    165172
Note: See TracChangeset for help on using the changeset viewer.