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
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.