Qt,Qt5,Qt6: Fixed LpToDp() result. issue #40817

This commit is contained in:
Željan Rikalo 2024-03-05 15:37:57 +01:00
parent 7d3626f6d7
commit 42ad212654
3 changed files with 30 additions and 6 deletions

View File

@ -5133,6 +5133,8 @@ var
QtPoint: TQtPoint;
Matrix: QTransformH;
QtDC: TQtDeviceContext;
RW, RV: TRect;
AScaleX, AScaleY: double;
begin
Result := False;
@ -5142,6 +5144,12 @@ begin
QtDC := TQtDeviceContext(DC);
Matrix := QPainter_transform(QtDC.Widget);
QPainter_window(QtDC.Widget, @RW);
QPainter_viewport(QtDC.Widget, @RV);
AScaleX := RW.Width / RV.Width;
AScaleY := RW.Height / RV.Height;
P := @Points;
while Count > 0 do
begin
@ -5149,8 +5157,8 @@ begin
QtPoint.X := P^.X;
QtPoint.Y := P^.Y;
QTransform_map(Matrix, PQtPoint(@QtPoint), PQtPoint(@QtPoint));
P^.X := QtPoint.X;
P^.Y := QtPoint.Y;
P^.X := Trunc(QtPoint.X / AScaleX) + RV.Left;
P^.Y := Trunc(QtPoint.Y / AScaleY) + RV.Top;
Inc(P);
end;

View File

@ -5079,6 +5079,8 @@ var
QtPoint: TQtPoint;
Matrix: QTransformH;
QtDC: TQtDeviceContext;
RW, RV: TRect;
AScaleX, AScaleY: double;
begin
Result := False;
@ -5088,6 +5090,12 @@ begin
QtDC := TQtDeviceContext(DC);
Matrix := QPainter_transform(QtDC.Widget);
QPainter_window(QtDC.Widget, @RW);
QPainter_viewport(QtDC.Widget, @RV);
AScaleX := RW.Width / RV.Width;
AScaleY := RW.Height / RV.Height;
P := @Points;
while Count > 0 do
begin
@ -5095,8 +5103,8 @@ begin
QtPoint.X := P^.X;
QtPoint.Y := P^.Y;
QTransform_map(Matrix, PQtPoint(@QtPoint), PQtPoint(@QtPoint));
P^.X := QtPoint.X;
P^.Y := QtPoint.Y;
P^.X := Trunc(QtPoint.X / AScaleX) + RV.Left;
P^.Y := Trunc(QtPoint.Y / AScaleY) + RV.Top;
Inc(P);
end;

View File

@ -5094,6 +5094,8 @@ var
QtPoint: TQtPoint;
Matrix: QTransformH;
QtDC: TQtDeviceContext;
RW, RV: TRect;
AScaleX, AScaleY: double;
begin
Result := False;
@ -5103,6 +5105,12 @@ begin
QtDC := TQtDeviceContext(DC);
Matrix := QPainter_transform(QtDC.Widget);
QPainter_window(QtDC.Widget, @RW);
QPainter_viewport(QtDC.Widget, @RV);
AScaleX := RW.Width / RV.Width;
AScaleY := RW.Height / RV.Height;
P := @Points;
while Count > 0 do
begin
@ -5110,8 +5118,8 @@ begin
QtPoint.X := P^.X;
QtPoint.Y := P^.Y;
QTransform_map(Matrix, PQtPoint(@QtPoint), PQtPoint(@QtPoint));
P^.X := QtPoint.X;
P^.Y := QtPoint.Y;
P^.X := Trunc(QtPoint.X / AScaleX) + RV.Left;
P^.Y := Trunc(QtPoint.Y / AScaleY) + RV.Top;
Inc(P);
end;