diff options
author | Alexander Akulich <akulichalexander@gmail.com> | 2019-10-04 16:10:19 +0300 |
---|---|---|
committer | Alexander Akulich <akulichalexander@gmail.com> | 2019-10-09 17:04:48 +0300 |
commit | 0d74b36864c9bc304acb68e6a5b56dad4fca2210 (patch) | |
tree | abaddb7c437eaf8e54d21a6764b94d95e190bf43 /src | |
parent | 44c51303b6968a4c8c5cf80fa92618852d017fd0 (diff) |
QQuickImage: Fix an odd 1px offset on 'fillMode: PreserveAspectFit'
We used to ceil x and y offsets on default (AlignHCenter) PreserveAspectFit
image. Consider the follow code:
width = 256;
pixWidth = 255.99;
xOffset = ceil((width - pixWidth) / 2);
It means that we use 1px offset to center an image that is 0.01px tighter
than its view. This actually leads to painting outside of the bounding rect.
Use simple integer division to calculate x and y offsets.
Task-number: QTBUG-79011
Change-Id: I76f2fe3361b820c48202f8f872e2ddb58a65016e
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/quick/items/qquickimage.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/quick/items/qquickimage.cpp b/src/quick/items/qquickimage.cpp index 4a0936b4d5..16343774e2 100644 --- a/src/quick/items/qquickimage.cpp +++ b/src/quick/items/qquickimage.cpp @@ -676,13 +676,13 @@ QSGNode *QQuickImage::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) int xOffset = 0; if (d->hAlign == QQuickImage::AlignHCenter) - xOffset = qCeil((width() - pixWidth) / 2.); + xOffset = (width() - pixWidth) / 2; else if (d->hAlign == QQuickImage::AlignRight) xOffset = qCeil(width() - pixWidth); int yOffset = 0; if (d->vAlign == QQuickImage::AlignVCenter) - yOffset = qCeil((height() - pixHeight) / 2.); + yOffset = (height() - pixHeight) / 2; else if (d->vAlign == QQuickImage::AlignBottom) yOffset = qCeil(height() - pixHeight); |