Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-79011

Rendering of an Image with PreserveAspectFit is inaccurate

    XMLWordPrintable

Details

    • All

    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

          For Gerrit Dashboard: QTBUG-79011
          # Subject Branch Project Status CR V

          Activity

            People

              qt.team.quick.subscriptions Qt Quick and Widgets Team
              kaffeine Alexandr Akulich
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes