From 0d9b37493fd209a085dacbf8557cc348c4edee75 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Tue, 20 Jul 2021 13:24:07 +0200 Subject: Scale image with MDI icons using the correction factor The buffer might be large than needed and contain a lot of uninitialized pixels. Scaling it down to the requested size is wrong, we need to scale it by the correction factor. Amends e56b8e1e59b6df7c7abd48b163abe6846849eb7a. As a drive-by, make the correction factor helper function static. Fixes: QTBUG-94733 Change-Id: Ia5be2a77459321e30485d330b49cf57fdbb664d2 Reviewed-by: Friedemann Kleint (cherry picked from commit 5d7a58ea45ed834655220e05012ff17ac235131a) Reviewed-by: Qt Cherry-pick Bot --- src/plugins/styles/windowsvista/qwindowsxpstyle.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp b/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp index e9df7a1e8c..000c27e685 100644 --- a/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp +++ b/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp @@ -997,7 +997,7 @@ bool QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(XPThemeData &themeDa #endif img = QImage(bufferPixels, bufferW, bufferH, format); if (hasCorrectionFactor) - img = img.scaled(w, h, Qt::KeepAspectRatio, Qt::SmoothTransformation); + img = img.scaled(img.size() * correctionFactor, Qt::KeepAspectRatio, Qt::SmoothTransformation); img.setDevicePixelRatio(additionalDevicePixelRatio); } @@ -2293,7 +2293,7 @@ static void populateMdiButtonTheme(const QStyle *proxy, const QWidget *widget, // Calculate an small (max 2), empirical correction factor for scaling up // WP_MDICLOSEBUTTON, WP_MDIRESTOREBUTTON, WP_MDIMINBUTTON, which are too // small on High DPI screens (QTBUG-75927). -qreal mdiButtonCorrectionFactor(XPThemeData &theme, const QPaintDevice *pd = nullptr) +static qreal mdiButtonCorrectionFactor(XPThemeData &theme, const QPaintDevice *pd = nullptr) { const auto dpr = pd ? pd->devicePixelRatio() : qApp->devicePixelRatio(); const QSizeF nativeSize = QSizeF(theme.size()) / dpr; -- cgit v1.2.3