mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-22 08:59:32 +02:00
Qt5,Qt6: fixed distorted image creation from device (screenshoot) on HiDpi screens.
(cherry-picked from commit 291a9fd3dd
)
Co-authored-by: zeljan1 <zeljko@holobit.hr>
This commit is contained in:
parent
a540e7372b
commit
2754524965
@ -755,6 +755,7 @@ var
|
||||
Image: QImageH;
|
||||
Context: TQtDeviceContext;
|
||||
AWnd: HWND;
|
||||
APixelRatio: QReal;
|
||||
|
||||
procedure RawImage_FromImage(AImage: QImageH);
|
||||
begin
|
||||
@ -788,8 +789,8 @@ begin
|
||||
if Context.Parent <> nil then
|
||||
begin
|
||||
AWnd := HwndFromWidgetH(Context.Parent);
|
||||
// AWnd should never be 0 at this point
|
||||
APixmap := TQtWidget(AWnd).grabWindow(0, 0, DCSize.cx, DCSize.cy, Context.Parent);
|
||||
APixelRatio := QScreen_devicePixelRatio(QWindow_screen(QWidget_windowHandle(Context.Parent)));
|
||||
APixmap := TQtWidget(AWnd).grabWindow(0, 0, Round(DCSize.cx / APixelRatio), Round(DCSize.cy / APixelRatio), Context.Parent);
|
||||
Image := QImage_Create;
|
||||
QPixmap_toImage(APixmap, Image);
|
||||
RawImage_FromImage(Image);
|
||||
|
@ -774,6 +774,7 @@ var
|
||||
Image: QImageH;
|
||||
Context: TQtDeviceContext;
|
||||
AWnd: HWND;
|
||||
APixelRatio: QReal;
|
||||
|
||||
procedure RawImage_FromImage(AImage: QImageH);
|
||||
begin
|
||||
@ -807,8 +808,8 @@ begin
|
||||
if Context.Parent <> nil then
|
||||
begin
|
||||
AWnd := HwndFromWidgetH(Context.Parent);
|
||||
// AWnd should never be 0 at this point
|
||||
APixmap := TQtWidget(AWnd).grabWindow(0, 0, DCSize.cx, DCSize.cy, Context.Parent);
|
||||
APixelRatio := QScreen_devicePixelRatio(QWidget_screen(Context.Parent));
|
||||
APixmap := TQtWidget(AWnd).grabWindow(0, 0, Round(DCSize.cx / APixelRatio), Round(DCSize.cy / APixelRatio), Context.Parent);
|
||||
Image := QImage_Create;
|
||||
QPixmap_toImage(APixmap, Image);
|
||||
RawImage_FromImage(Image);
|
||||
|
Loading…
Reference in New Issue
Block a user