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

QImageReader incorrectly set DevicePixelRatio to 1.0 for filenames containing a '.'

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.10.1
    • None
    • The bug has been reproduced with Qt 5.10.1 on:
       * macOS 10.13 with Retina screen
       * Windows 10 with HiDPI screen
    • macOS

    Description

       

      If you have an image whose filename contains a dot, QImageReader will incorrectly set the devicePixelRatio to 1.0 when it should be set to 2.0.

      For example, when running these lines on a Mac with Retina screen, the pixmap will have its DevicePixelRatio set to 1.0:

      QString fileName = QString(":/images/category.active@2x.png");
      QPixmap pixmap = fileName;

      The bug occurs in qimagereader.cpp:1372:

          if (!disable2xImageLoading && QFileInfo(fileName()).baseName().endsWith(QLatin1String("@2x"))) {
                 image->setDevicePixelRatio(2.0);
          }

      For a fileName like 

      :/images/category.active@2x.png

      the baseName will be "category" and as such the condition fails and the devicePixelRatio is not set to 2.0.

       

      Attachments

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

        Activity

          People

            sorvig Morten Sørvig
            jirauser46068 user-e3f1a (Inactive)
            Veli-Pekka Heinonen Veli-Pekka Heinonen
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes