From 7b9197eea1c21fb8aaa973176d4371ba9e5cd23e Mon Sep 17 00:00:00 2001 From: LKM Date: Thu, 2 Jul 2020 09:16:16 +0800 Subject: [PATCH] fix: #716 --- src/ui/windows/w_ScreenShot_Core.cpp | 6 +++--- src/ui/windows/w_ScreenShot_Core.hpp | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/ui/windows/w_ScreenShot_Core.cpp b/src/ui/windows/w_ScreenShot_Core.cpp index 2b8b7988..0df5e7d1 100644 --- a/src/ui/windows/w_ScreenShot_Core.cpp +++ b/src/ui/windows/w_ScreenShot_Core.cpp @@ -39,6 +39,7 @@ QImage ScreenShotWindow::DoScreenShot() QApplication::processEvents(); // desktopImage = qApp->screenAt(QCursor::pos())->grabWindow(0); + scale = qApp->screenAt(QCursor::pos())->devicePixelRatio(); // int w = desktopImage.width(); int h = desktopImage.height(); @@ -58,7 +59,7 @@ QImage ScreenShotWindow::DoScreenShot() } } setStyleSheet("QDialog { background-color: transparent; }"); - bg_grey = bg_grey.scaled(bg_grey.size() / devicePixelRatio(), Qt::KeepAspectRatio, Qt::TransformationMode::SmoothTransformation); + bg_grey = bg_grey.scaled(bg_grey.size() / scale, Qt::KeepAspectRatio, Qt::TransformationMode::SmoothTransformation); auto p = this->palette(); p.setBrush(QPalette::Window, bg_grey); setPalette(p); @@ -78,8 +79,7 @@ void ScreenShotWindow::pSize() imgY = origin.y() < end.y() ? origin.y() : end.y(); rubber.setGeometry(imgX, imgY, imgW, imgH); fg->setGeometry(rubber.geometry()); - fg->setPixmap(desktopImage.copy(fg->x() * devicePixelRatio(), fg->y() * devicePixelRatio(), fg->width() * devicePixelRatio(), - fg->height() * devicePixelRatio())); + fg->setPixmap(desktopImage.copy(imgX * scale, imgY * scale, imgW * scale, imgH * scale)); } bool ScreenShotWindow::event(QEvent *e) diff --git a/src/ui/windows/w_ScreenShot_Core.hpp b/src/ui/windows/w_ScreenShot_Core.hpp index a7823204..366e51c6 100644 --- a/src/ui/windows/w_ScreenShot_Core.hpp +++ b/src/ui/windows/w_ScreenShot_Core.hpp @@ -34,6 +34,7 @@ class ScreenShotWindow void on_startBtn_clicked(); private: + double scale; QRubberBand rubber; // Desktop Image QPixmap desktopImage;