From d835e5ef719356c3840c11aade9e671a26d5c6ce Mon Sep 17 00:00:00 2001 From: letsfindaway Date: Sun, 9 Jan 2022 10:40:12 +0100 Subject: [PATCH] fix: scaling of mirror pixmap - when scaling the pixmap take the devicePixelRatio into account - do not scale the already scaled pixmap when drawing in UBScreenMirror - use device independent coordinates when positioning the pixmap --- src/gui/UBScreenMirror.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/gui/UBScreenMirror.cpp b/src/gui/UBScreenMirror.cpp index db5b65116..ff9810862 100644 --- a/src/gui/UBScreenMirror.cpp +++ b/src/gui/UBScreenMirror.cpp @@ -66,10 +66,12 @@ void UBScreenMirror::paintEvent(QPaintEvent *event) if (!mLastPixmap.isNull()) { - int x = (width() - mLastPixmap.width()) / 2; - int y = (height() - mLastPixmap.height()) / 2; + // compute size and offset in device independent coordinates + QSizeF pixmapSize = mLastPixmap.size() / mLastPixmap.devicePixelRatioF(); + int x = (width() - pixmapSize.width()) / 2; + int y = (height() - pixmapSize.height()) / 2; - painter.drawPixmap(x, y, width(), height(), mLastPixmap); + painter.drawPixmap(x, y, mLastPixmap); } } @@ -95,7 +97,7 @@ void UBScreenMirror::grabPixmap() } if (!mLastPixmap.isNull()) - mLastPixmap = mLastPixmap.scaled(width(), height(), Qt::KeepAspectRatio, Qt::SmoothTransformation); + mLastPixmap = mLastPixmap.scaled(size() * mLastPixmap.devicePixelRatioF(), Qt::KeepAspectRatio, Qt::SmoothTransformation); }