From 9595622e366fcbef6bcc3a2ee08597959e3e2bd2 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 18 Apr 2017 14:47:46 +0200 Subject: QGraphicsBlurEffect: Fix for high DPI scaling Preserve the device pixel ratio in the various helper functions and when drawing. Task-number: QTBUG-60026 Change-Id: Ieac9360b00044b6aedd0d3e1ad6e3b16d436f20f Reviewed-by: Allan Sandfeld Jensen --- src/widgets/effects/qpixmapfilter.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/effects/qpixmapfilter.cpp b/src/widgets/effects/qpixmapfilter.cpp index bb949fcebf..999e551af4 100644 --- a/src/widgets/effects/qpixmapfilter.cpp +++ b/src/widgets/effects/qpixmapfilter.cpp @@ -719,6 +719,7 @@ void expblur(QImage &img, qreal radius, bool improvedQuality = false, int transp } QImage temp(img.height(), img.width(), img.format()); + temp.setDevicePixelRatio(img.devicePixelRatioF()); if (transposed >= 0) { if (img.depth() == 8) { qt_memrotate270(reinterpret_cast(img.bits()), @@ -780,6 +781,7 @@ Q_WIDGETS_EXPORT QImage qt_halfScaled(const QImage &source) if (source.format() == QImage::Format_Indexed8 || source.format() == QImage::Format_Grayscale8) { // assumes grayscale QImage dest(source.width() / 2, source.height() / 2, srcImage.format()); + dest.setDevicePixelRatio(source.devicePixelRatioF()); const uchar *src = reinterpret_cast(const_cast(srcImage).bits()); int sx = srcImage.bytesPerLine(); @@ -801,6 +803,7 @@ Q_WIDGETS_EXPORT QImage qt_halfScaled(const QImage &source) return dest; } else if (source.format() == QImage::Format_ARGB8565_Premultiplied) { QImage dest(source.width() / 2, source.height() / 2, srcImage.format()); + dest.setDevicePixelRatio(source.devicePixelRatioF()); const uchar *src = reinterpret_cast(const_cast(srcImage).bits()); int sx = srcImage.bytesPerLine(); @@ -837,6 +840,7 @@ Q_WIDGETS_EXPORT QImage qt_halfScaled(const QImage &source) } QImage dest(source.width() / 2, source.height() / 2, srcImage.format()); + dest.setDevicePixelRatio(source.devicePixelRatioF()); const quint32 *src = reinterpret_cast(const_cast(srcImage).bits()); int sx = srcImage.bytesPerLine() >> 2; @@ -881,7 +885,7 @@ Q_WIDGETS_EXPORT void qt_blurImage(QPainter *p, QImage &blurImage, qreal radius, if (p) { p->scale(scale, scale); p->setRenderHint(QPainter::SmoothPixmapTransform); - p->drawImage(QRect(0, 0, blurImage.width(), blurImage.height()), blurImage); + p->drawImage(QRect(QPoint(0, 0), blurImage.size() / blurImage.devicePixelRatioF()), blurImage); } } -- cgit v1.2.3