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();
//
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)

View File

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