Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
5.12.5
-
None
Description
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).
Attachments
Issue Links
- is duplicated by
-
QTBUG-79590 Image: center aligned & PreserveAspectFit can result in small misalignment of painted img
- Closed