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

High DPI rounding error

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: P2: Important
    • Resolution: Unresolved
    • Affects Version/s: 5.15.2, 5.15.3, 6.1.0 Beta3
    • Fix Version/s: None
    • Component/s: GUI: High-DPI
    • Platform/s:
      Windows

      Description

      Qt seems to use different roundings when calculating pixel values from device independent pixels, I have not checked the Qt source code, but I have done some testing.

      My screen is set to 125% scaling so I have a device pixel ratio of 1.25 in Qt.

      Calling the following method

       

      QPixmap pixmap = icon.pixmap(QSize(26, 26));

      Results in a pixmap that is 33x33 pixels

      26 * 1.25 = 32.5 rounded up to 33

      Then calling

      painter.drawPixmap(QRect(0,0,26,26), pixmap);
      

      This renders an image that is 32x32 pixels big.

      26 * 1.25 = 32.5 rounded down to 32

      This causes a bitmap scaling to occur from 33x33 -> 32x32 pixels, which results in a distorted image.

       

       

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            sorvig Morten Sørvig
            Reporter:
            jonaslarsson Jonas Larsson
            PM Owner:
            Veli-Pekka Heinonen Veli-Pekka Heinonen
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes