mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 10:39:30 +02:00
Qt5,Qt6: fixed distorted image creation from device (screenshoot) on HiDpi screens.
This commit is contained in:
parent
32c1370c50
commit
291a9fd3dd
@ -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