This commit is contained in:
LKM 2020-07-02 09:16:16 +08:00 committed by DuckSoft
parent 6fac6616b6
commit 7b9197eea1
2 changed files with 4 additions and 3 deletions

View File

@ -39,6 +39,7 @@ QImage ScreenShotWindow::DoScreenShot()
QApplication::processEvents(); QApplication::processEvents();
// //
desktopImage = qApp->screenAt(QCursor::pos())->grabWindow(0); desktopImage = qApp->screenAt(QCursor::pos())->grabWindow(0);
scale = qApp->screenAt(QCursor::pos())->devicePixelRatio();
// //
int w = desktopImage.width(); int w = desktopImage.width();
int h = desktopImage.height(); int h = desktopImage.height();
@ -58,7 +59,7 @@ QImage ScreenShotWindow::DoScreenShot()
} }
} }
setStyleSheet("QDialog { background-color: transparent; }"); 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(); auto p = this->palette();
p.setBrush(QPalette::Window, bg_grey); p.setBrush(QPalette::Window, bg_grey);
setPalette(p); setPalette(p);
@ -78,8 +79,7 @@ void ScreenShotWindow::pSize()
imgY = origin.y() < end.y() ? origin.y() : end.y(); imgY = origin.y() < end.y() ? origin.y() : end.y();
rubber.setGeometry(imgX, imgY, imgW, imgH); rubber.setGeometry(imgX, imgY, imgW, imgH);
fg->setGeometry(rubber.geometry()); fg->setGeometry(rubber.geometry());
fg->setPixmap(desktopImage.copy(fg->x() * devicePixelRatio(), fg->y() * devicePixelRatio(), fg->width() * devicePixelRatio(), fg->setPixmap(desktopImage.copy(imgX * scale, imgY * scale, imgW * scale, imgH * scale));
fg->height() * devicePixelRatio()));
} }
bool ScreenShotWindow::event(QEvent *e) bool ScreenShotWindow::event(QEvent *e)

View File

@ -34,6 +34,7 @@ class ScreenShotWindow
void on_startBtn_clicked(); void on_startBtn_clicked();
private: private:
double scale;
QRubberBand rubber; QRubberBand rubber;
// Desktop Image // Desktop Image
QPixmap desktopImage; QPixmap desktopImage;