summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtextimagehandler.cpp
diff options
context:
space:
mode:
authorMorten Sørvig <morten.sorvig@qt.io>2021-08-16 08:41:57 +0200
committerMorten Sørvig <morten.sorvig@qt.io>2021-09-01 15:24:05 +0200
commit81a7344e1dea562271865ddf94a7d7138e663ce4 (patch)
tree3289768b62776ec2d93619043253955aad169843 /src/gui/text/qtextimagehandler.cpp
parent4e460aa3f7fb5aa2f66a2a75b0aea82464ee5639 (diff)
Port to QImage and QPixmap deviceIndependentSize()
Replace the “size() / devicePixelRatio()” pattern with a call to deviceIndependentSize(). Change-Id: I9d9359e80b9e6643e7395028cd43e3261d449ae7 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/gui/text/qtextimagehandler.cpp')
-rw-r--r--src/gui/text/qtextimagehandler.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/gui/text/qtextimagehandler.cpp b/src/gui/text/qtextimagehandler.cpp
index 290aa256cb..2872366208 100644
--- a/src/gui/text/qtextimagehandler.cpp
+++ b/src/gui/text/qtextimagehandler.cpp
@@ -102,20 +102,19 @@ static QSize getPixmapSize(QTextDocument *doc, const QTextImageFormat &format)
QSize size(width, height);
if (!hasWidth || !hasHeight) {
pm = getPixmap(doc, format);
- const int pmWidth = pm.width() / pm.devicePixelRatio();
- const int pmHeight = pm.height() / pm.devicePixelRatio();
+ const QSizeF pmSize = pm.deviceIndependentSize();
if (!hasWidth) {
if (!hasHeight)
- size.setWidth(pmWidth);
+ size.setWidth(pmSize.width());
else
- size.setWidth(qRound(height * (pmWidth / (qreal) pmHeight)));
+ size.setWidth(qRound(height * (pmSize.width() / (qreal) pmSize.height())));
}
if (!hasHeight) {
if (!hasWidth)
- size.setHeight(pmHeight);
+ size.setHeight(pmSize.height());
else
- size.setHeight(qRound(width * (pmHeight / (qreal) pmWidth)));
+ size.setHeight(qRound(width * (pmSize.height() / (qreal) pmSize.width())));
}
}
@@ -171,10 +170,11 @@ static QSize getImageSize(QTextDocument *doc, const QTextImageFormat &format)
QSize size(width, height);
if (!hasWidth || !hasHeight) {
image = getImage(doc, format);
+ QSizeF imageSize = image.deviceIndependentSize();
if (!hasWidth)
- size.setWidth(image.width() / image.devicePixelRatio());
+ size.setWidth(imageSize.width());
if (!hasHeight)
- size.setHeight(image.height() / image.devicePixelRatio());
+ size.setHeight(imageSize.height());
}
qreal scale = 1.0;