Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.7
-
None
Description
As explained on QTBUG-122705:
If you set only Image.sourceSize.width or Drag.imageSourceSize.width to a smaller value than the image's "natural" size, and then call QQuickImageProviderWithOptions::loadSize() with options having preserveAspectRatioFit(), you expect that it will return a size that fits into the width or the height, whichever makes the image smaller (as long as it's greater than zero); but instead, it returns an anamorphic size, where width is whatever you set and height is from the image's natural size.
This has several causes / obstacles to deal with:
- QQuickImageBase::sourceSize() and QQuickDragAttached::imageSourceSize() return the size from the pixmapLoader for each dimension that was not set. This is a way of providing information to a user who might want to get the natural size from the property; but if the pixmapLoader has already loaded the image with its "natural" size, and then you change sourceSize.width, to call the setter you have to first call the getter, change its width, and then set it back again. So you only changed the width, and by not mentioning the height, you didn't set it to 0. But if the image wasn't loaded, the height is not known, and therefore still 0. This is inconsistent.
- QQuickImageProviderWithOptions::loadSize() treats preserveAspectRatioFit() and preserveAspectRatioCrop() exactly the same. That doesn't make sense IMO. One should be trying to minimize the size to fit both ways; the other should be trying to maximize it, to fit one dimension and crop the other. (Need to amend https://codereview.qt-project.org/c/qt/qtdeclarative/+/189379 )
- In the case of the Drag attached property: if we want to fix it by delaying loading until component complete, to make the behavior independent of the order of setting properties (in case you set imageSource first and then imageSourceSize afterwards) and thereby avoid imageSourceSize() returning the "known" size too early, we run into QTBUG-39079: if there is a way to find out when the component is complete, it's harder than it is for an Item, to say the least.
Attachments
Issue Links
- relates to
-
QTBUG-115535 Can't always get a non-blurry image in all cases using QML Image
- Reported
-
QTBUG-109064 Image.sourceSize changes when loaded locally
- Reported
-
QTBUG-17269 Using Image.PreserveAspectFit results in inconsistent implicit/source size
- Reported
-
QTBUG-115039 AnimatedImage: setting sourceSize.width or height alone doesn't work
- Closed
- resulted from
-
QTBUG-122705 Drag.imageSource property should have hi-dpi support
- Closed