diff options
author | Eirik Aavitsland <eirik.aavitsland@qt.io> | 2019-06-14 13:08:56 +0200 |
---|---|---|
committer | Eirik Aavitsland <eirik.aavitsland@qt.io> | 2019-06-14 13:08:56 +0200 |
commit | 3797704c4ff0d91f544efa791973eced07c3ef02 (patch) | |
tree | 91c0c44916a5f651d4f826e7b43265b7cedaf02d /src/gui/image | |
parent | 2c9ba8474681abbd4c9eb87e8030e386b631e921 (diff) |
Generalize image file name @2x suffix handling to higher scale factors
@3x is in use on iOS already, so extend the handling in QImageReader
to all single-digit factors, like QIcon does.
Fixes: QTBUG-76273
Change-Id: Ic9442731c0549dbe8f797e1ddb1a09d8447e8441
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'src/gui/image')
-rw-r--r-- | src/gui/image/qimagereader.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/gui/image/qimagereader.cpp b/src/gui/image/qimagereader.cpp index 0fb1d808e5..0c75196612 100644 --- a/src/gui/image/qimagereader.cpp +++ b/src/gui/image/qimagereader.cpp @@ -1319,10 +1319,12 @@ bool QImageReader::read(QImage *image) } } - // successful read; check for "@2x" file name suffix and set device pixel ratio. - static bool disable2xImageLoading = !qEnvironmentVariableIsEmpty("QT_HIGHDPI_DISABLE_2X_IMAGE_LOADING"); - if (!disable2xImageLoading && QFileInfo(fileName()).baseName().endsWith(QLatin1String("@2x"))) { - image->setDevicePixelRatio(2.0); + // successful read; check for "@Nx" file name suffix and set device pixel ratio. + static bool disableNxImageLoading = !qEnvironmentVariableIsEmpty("QT_HIGHDPI_DISABLE_2X_IMAGE_LOADING"); + if (!disableNxImageLoading) { + const QByteArray suffix = QFileInfo(fileName()).baseName().right(3).toLatin1(); + if (suffix.length() == 3 && suffix[0] == '@' && suffix[1] >= '2' && suffix[1] <= '9' && suffix[2] == 'x') + image->setDevicePixelRatio(suffix[1] - '0'); } if (autoTransform()) qt_imageTransform(*image, transformation()); |