From f4cd58a9b713bc48c0412e8d988533c883c3997b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kaj=20Gr=C3=B6nholm?= Date: Tue, 12 Sep 2023 09:56:54 +0300 Subject: [PATCH] Round the image scaling when not antialiased MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When painting an image with antialiasing not turned on, round the target area to closest integers (pixels). Task-number: QTBUG-116297 Change-Id: I64e78a9087ee042aef0ea297c48b5ead36697d10 Reviewed-by: Eirik Aavitsland Reviewed-by: Tomi Korpipää (cherry picked from commit 743c1cf96bae2722ac70a551c7d66b7d2f6a65d8) Reviewed-by: Qt Cherry-pick Bot --- src/gui/painting/qpaintengine_raster.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index a50f5aec60e..7afa321ef6c 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -2342,9 +2342,16 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe } SrcOverScaleFunc func = qScaleFunctions[d->rasterBuffer->format][img.format()]; if (func && (!clip || clip->hasRectClip)) { + QRectF tr = qt_mapRect_non_normalizing(r, s->matrix); + if (!s->flags.antialiased) { + tr.setX(qRound(tr.x())); + tr.setY(qRound(tr.y())); + tr.setWidth(qRound(tr.width())); + tr.setHeight(qRound(tr.height())); + } func(d->rasterBuffer->buffer(), d->rasterBuffer->bytesPerLine(), img.bits(), img.bytesPerLine(), img.height(), - qt_mapRect_non_normalizing(r, s->matrix), sr, + tr, sr, !clip ? d->deviceRect : clip->clipRect, s->intOpacity); return;