Changeset 559 for trunk/Packages/DpiControls/NativePixelPointer.pas
- Timestamp:
- Apr 25, 2024, 8:40:07 PM (3 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/DpiControls/NativePixelPointer.pas
r539 r559 50 50 Pixel: PPixel32; 51 51 Line: PPixel32; 52 RelLine: PPixel32;53 52 BytesPerPixel: Integer; 54 53 BytesPerLine: Integer; … … 62 61 procedure SetXY(X, Y: Integer); inline; // Set pixel position relative to base 63 62 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 64 65 procedure CheckRange; inline; // Check if current pixel position is not out of range 65 66 function PosValid: Boolean; … … 117 118 end; 118 119 119 procedure TPixelPointer.PreviousLine; 120 procedure TPixelPointer.PreviousLine; inline; 120 121 begin 121 122 Line := Pointer(Line) - BytesPerLine; … … 128 129 end; 129 130 130 procedure TPixelPointer.PreviousPixel; 131 procedure TPixelPointer.PreviousPixel; inline; 131 132 begin 132 133 Pixel := Pointer(Pixel) - BytesPerPixel; … … 144 145 end; 145 146 147 function TPixelPointer.GetY: Integer; inline; 148 begin 149 Result := (Pointer(Base) - Line) div BytesPerLine; 150 end; 151 152 function TPixelPointer.GetX: Integer; inline; 153 begin 154 Result := (Pointer(Line) - Pixel) div BytesPerPixel; 155 end; 156 146 157 procedure TPixelPointer.CheckRange; 147 158 {$IFOPT R+} … … 149 160 X: Integer; 150 161 Y: Integer; 162 D: Integer; 151 163 {$ENDIF} 152 164 begin … … 154 166 if (PByte(Pixel) < PByte(Data)) or 155 167 (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); 160 172 raise Exception.Create(Format(SOutOfRange, [X, Y, Width, Height])); 161 173 end;
Note:
See TracChangeset
for help on using the changeset viewer.