On certain image size the Fit fill mode doesn't work right.
We used to qCeil x and y offsets on default Image with fillMode: PreserveAspectFit (the default horizontal alignment is AlignHCenter). Consider the follow code:
width = 256; pixWidth = 255.99; xOffset = ceil((width - pixWidth) / 2);
The result 1px xOffset means that in order to place the image (which is 0.01px tighter than its view) to the view center, we move it to the right by 1px. This leads to painting outside of the bounding rectangle (and becomes a subject for `clip: true`).
screenshot-1.png shows the inaccurate rendering of an Image with explicit size 128x72 and loaded image file (504x284 red rectangle).
In case of the offset fixed we still have another kind of artifacts because of the small diff between width and pixWidth (or between height and pixHeight). See screenshot-2.png for the demonstration (it is the same code from the attachment with a bigger scaling to make the issue more visible).
The second issue is noticeable on HighDPI screens in real-world applications (I develop an app that hit this).
- is duplicated by
QTBUG-79590 Image: center aligned & PreserveAspectFit can result in small misalignment of painted img
|For Gerrit Dashboard: QTBUG-79011|
|276372,3||QQuickImage: Fix an odd 1px offset on 'fillMode: PreserveAspectFit'||5.13||qt/qtdeclarative||Status: MERGED||+2||0|
|276381,2||QQuickImage: Snap painted size to Item size if diff is less than 0.5px||5.13||qt/qtdeclarative||Status: ABANDONED||0||0|
|276888,2||QQuickImage: Fix an odd 1px offset on 'fillMode: PreserveAspectFit'||5.12||qt/qtdeclarative||Status: ABANDONED||-1||0|