summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qpagesize.cpp
diff options
context:
space:
mode:
authorJarkko Koivikko <jarkko.koivikko@code-q.fi>2023-11-27 15:07:51 +0200
committerJarkko Koivikko <jarkko.koivikko@code-q.fi>2023-12-09 04:46:24 +0200
commitc49fd15a4253a79d70ae2b26ac4cc04454ffd7a0 (patch)
tree3318affe643ff87985db9331f4812493f540820d /src/gui/painting/qpagesize.cpp
parentd420c1e25a0fb3b25ba4c572f2938701ce8494ec (diff)
pagesize: Fix pixel overflow in QPageSize::sizePixels and rectPixels
This update addresses an issue in converting page size from points to device pixels. Previously, rounding the result could lead to an overflow beyond the physical pixel capacity. Example case: A4 paper size at 600 dpi: - points to pixels: 842 pt / (72.0 / 600) = 7016.666666666667 However, the physical pixel height for an HP printer: - GetDeviceCaps(hdc, PHYSICALHEIGHT)) = 7016 This fix prevents pixel size from exceeding the physical print area, avoiding unprinted pixels. Pick-to: 6.6 Change-Id: I66eabc628d3374d9cfb19b0eb5928f83afbc13dc Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'src/gui/painting/qpagesize.cpp')
-rw-r--r--src/gui/painting/qpagesize.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/gui/painting/qpagesize.cpp b/src/gui/painting/qpagesize.cpp
index 3ed633bf99..4c453c830f 100644
--- a/src/gui/painting/qpagesize.cpp
+++ b/src/gui/painting/qpagesize.cpp
@@ -543,7 +543,7 @@ static QSize qt_convertPointsToPixels(const QSize &size, int resolution)
if (!size.isValid() || resolution <= 0)
return QSize();
const qreal multiplier = qt_pixelMultiplier(resolution);
- return QSize(qRound(size.width() / multiplier), qRound(size.height() / multiplier));
+ return QSize(qFloor(size.width() / multiplier), qFloor(size.height() / multiplier));
}
static QSizeF qt_convertPointsToUnits(const QSize &size, QPageSize::Unit units)