diff options
author | Jason Haslam <jason@scitools.com> | 2015-10-02 11:56:29 -0600 |
---|---|---|
committer | Morten Johan Sørvig <morten.sorvig@theqtcompany.com> | 2016-04-05 11:43:36 +0000 |
commit | 65aff4dc422f53faa44e961850cb4f1e4501a8c7 (patch) | |
tree | 57f74ce5eb919fe94c6e9c0cedec10f3673b6904 | |
parent | bebf89e1379d6948728a4ebd669de6b63dc3f426 (diff) |
Fix regression in scaled QLabel on hi-res display.
The change in bc1796f for QTBUG-42503 only works for scaling down
pixel-doubled images. Smaller images scale up incorrectly. Fixed by
setting the devicePixelRatio of the scaled pixmap to the
devicePixelRatio of the label.
Also, caching was broken by not accounting for scaling by
devicePixelRatio in the condition.
Change-Id: I6e1503652e61683a16312c74f46b79d28c880848
Task-number: QTBUG-46846
Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
-rw-r--r-- | src/widgets/widgets/qlabel.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/widgets/widgets/qlabel.cpp b/src/widgets/widgets/qlabel.cpp index 55e277026c..a07a964595 100644 --- a/src/widgets/widgets/qlabel.cpp +++ b/src/widgets/widgets/qlabel.cpp @@ -1091,14 +1091,16 @@ void QLabel::paintEvent(QPaintEvent *) if (d->pixmap && !d->pixmap->isNull()) { QPixmap pix; if (d->scaledcontents) { - if (!d->scaledpixmap || d->scaledpixmap->size() != cr.size()) { + QSize scaledSize = cr.size() * devicePixelRatioF(); + if (!d->scaledpixmap || d->scaledpixmap->size() != scaledSize) { if (!d->cachedimage) d->cachedimage = new QImage(d->pixmap->toImage()); delete d->scaledpixmap; QImage scaledImage = - d->cachedimage->scaled(cr.size() * devicePixelRatioF(), + d->cachedimage->scaled(scaledSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); d->scaledpixmap = new QPixmap(QPixmap::fromImage(scaledImage)); + d->scaledpixmap->setDevicePixelRatio(devicePixelRatioF()); } pix = *d->scaledpixmap; } else |