mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-19 00:39:26 +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;
|
Image: QImageH;
|
||||||
Context: TQtDeviceContext;
|
Context: TQtDeviceContext;
|
||||||
AWnd: HWND;
|
AWnd: HWND;
|
||||||
|
APixelRatio: QReal;
|
||||||
|
|
||||||
procedure RawImage_FromImage(AImage: QImageH);
|
procedure RawImage_FromImage(AImage: QImageH);
|
||||||
begin
|
begin
|
||||||
@ -788,8 +789,8 @@ begin
|
|||||||
if Context.Parent <> nil then
|
if Context.Parent <> nil then
|
||||||
begin
|
begin
|
||||||
AWnd := HwndFromWidgetH(Context.Parent);
|
AWnd := HwndFromWidgetH(Context.Parent);
|
||||||
// AWnd should never be 0 at this point
|
APixelRatio := QScreen_devicePixelRatio(QWindow_screen(QWidget_windowHandle(Context.Parent)));
|
||||||
APixmap := TQtWidget(AWnd).grabWindow(0, 0, DCSize.cx, DCSize.cy, Context.Parent);
|
APixmap := TQtWidget(AWnd).grabWindow(0, 0, Round(DCSize.cx / APixelRatio), Round(DCSize.cy / APixelRatio), Context.Parent);
|
||||||
Image := QImage_Create;
|
Image := QImage_Create;
|
||||||
QPixmap_toImage(APixmap, Image);
|
QPixmap_toImage(APixmap, Image);
|
||||||
RawImage_FromImage(Image);
|
RawImage_FromImage(Image);
|
||||||
|
@ -774,6 +774,7 @@ var
|
|||||||
Image: QImageH;
|
Image: QImageH;
|
||||||
Context: TQtDeviceContext;
|
Context: TQtDeviceContext;
|
||||||
AWnd: HWND;
|
AWnd: HWND;
|
||||||
|
APixelRatio: QReal;
|
||||||
|
|
||||||
procedure RawImage_FromImage(AImage: QImageH);
|
procedure RawImage_FromImage(AImage: QImageH);
|
||||||
begin
|
begin
|
||||||
@ -807,8 +808,8 @@ begin
|
|||||||
if Context.Parent <> nil then
|
if Context.Parent <> nil then
|
||||||
begin
|
begin
|
||||||
AWnd := HwndFromWidgetH(Context.Parent);
|
AWnd := HwndFromWidgetH(Context.Parent);
|
||||||
// AWnd should never be 0 at this point
|
APixelRatio := QScreen_devicePixelRatio(QWidget_screen(Context.Parent));
|
||||||
APixmap := TQtWidget(AWnd).grabWindow(0, 0, DCSize.cx, DCSize.cy, Context.Parent);
|
APixmap := TQtWidget(AWnd).grabWindow(0, 0, Round(DCSize.cx / APixelRatio), Round(DCSize.cy / APixelRatio), Context.Parent);
|
||||||
Image := QImage_Create;
|
Image := QImage_Create;
|
||||||
QPixmap_toImage(APixmap, Image);
|
QPixmap_toImage(APixmap, Image);
|
||||||
RawImage_FromImage(Image);
|
RawImage_FromImage(Image);
|
||||||
|
Loading…
Reference in New Issue
Block a user