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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: P2: Important
    • Resolution: Unresolved
    • Affects Version/s: 5.10.1
    • Fix Version/s: None
    • Labels:
      None
    • Environment:
      The bug has been reproduced with Qt 5.10.1 on:
       * macOS 10.13 with Retina screen
       * Windows 10 with HiDPI screen

      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

            • Assignee:
              sorvig Morten Sørvig
              Reporter:
              timac Alexandre Colucci
            • Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:

                Gerrit Reviews

                There are no open Gerrit changes