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

High DPI rounding error

    XMLWordPrintable

Details

    • 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

            sorvig Morten Sørvig
            jonaslarsson Jonas Larsson
            Veli-Pekka Heinonen Veli-Pekka Heinonen
            Votes:
            1 Vote for this issue
            Watchers:
            9 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes