Ignore:
Timestamp:
Apr 25, 2024, 8:40:07 PM (3 weeks ago)
Author:
chronos
Message:
File:
1 edited

Legend:

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

    r539 r559  
    5050    Pixel: PPixel32;
    5151    Line: PPixel32;
    52     RelLine: PPixel32;
    5352    BytesPerPixel: Integer;
    5453    BytesPerLine: Integer;
     
    6261    procedure SetXY(X, Y: Integer); inline; // Set pixel position relative to base
    6362    procedure SetX(X: Integer); inline; // Set horizontal pixel position relative to base
     63    function GetY: Integer; inline; // Set pixel position relative to base
     64    function GetX: Integer; inline; // Set horizontal pixel position relative to base
    6465    procedure CheckRange; inline; // Check if current pixel position is not out of range
    6566    function PosValid: Boolean;
     
    117118end;
    118119
    119 procedure TPixelPointer.PreviousLine;
     120procedure TPixelPointer.PreviousLine; inline;
    120121begin
    121122  Line := Pointer(Line) - BytesPerLine;
     
    128129end;
    129130
    130 procedure TPixelPointer.PreviousPixel;
     131procedure TPixelPointer.PreviousPixel; inline;
    131132begin
    132133  Pixel := Pointer(Pixel) - BytesPerPixel;
     
    144145end;
    145146
     147function TPixelPointer.GetY: Integer; inline;
     148begin
     149  Result := (Pointer(Base) - Line) div BytesPerLine;
     150end;
     151
     152function TPixelPointer.GetX: Integer; inline;
     153begin
     154  Result := (Pointer(Line) - Pixel) div BytesPerPixel;
     155end;
     156
    146157procedure TPixelPointer.CheckRange;
    147158{$IFOPT R+}
     
    149160  X: Integer;
    150161  Y: Integer;
     162  D: Integer;
    151163{$ENDIF}
    152164begin
     
    154166  if (PByte(Pixel) < PByte(Data)) or
    155167    (PByte(Pixel) >= PByte(Data) + Height * BytesPerLine) then begin
    156     X := PByte(Pixel) - PByte(Data);
    157     Y := Floor(X / BytesPerLine);
    158     X := X - Y * BytesPerLine;
    159     X := Floor(X / BytesPerPixel);
     168    D := PByte(Pixel) - PByte(Data);
     169    Y := Trunc(D / BytesPerLine);
     170    X := D - Y * BytesPerLine;
     171    X := Trunc(X / BytesPerPixel);
    160172    raise Exception.Create(Format(SOutOfRange, [X, Y, Width, Height]));
    161173  end;
Note: See TracChangeset for help on using the changeset viewer.