diff --git a/src/plugins/imageformats/ico/qicohandler.cpp b/src/plugins/imageformats/ico/qicohandler.cpp index 3bcf30bfc6..e58dde4e97 100644 --- a/src/plugins/imageformats/ico/qicohandler.cpp +++ b/src/plugins/imageformats/ico/qicohandler.cpp @@ -499,7 +499,7 @@ QImage ICOReader::iconAt(int index) if (!image.isNull()) { readBMP(image); if (!image.isNull()) { - if (icoAttrib.depth == 32) { + if (icoAttrib.nbits == 32) { img = std::move(image).convertToFormat(QImage::Format_ARGB32_Premultiplied); } else { QImage mask(image.width(), image.height(), QImage::Format_Mono); diff --git a/tests/auto/gui/image/qicoimageformat/icons/masked/24bpp.ico b/tests/auto/gui/image/qicoimageformat/icons/masked/24bpp.ico new file mode 100644 index 0000000000..7e9cfa2414 Binary files /dev/null and b/tests/auto/gui/image/qicoimageformat/icons/masked/24bpp.ico differ diff --git a/tests/auto/gui/image/qicoimageformat/icons/masked/24bpp.png b/tests/auto/gui/image/qicoimageformat/icons/masked/24bpp.png new file mode 100644 index 0000000000..f0a19c05e3 Binary files /dev/null and b/tests/auto/gui/image/qicoimageformat/icons/masked/24bpp.png differ diff --git a/tests/auto/gui/image/qicoimageformat/icons/masked/32bpp.ico b/tests/auto/gui/image/qicoimageformat/icons/masked/32bpp.ico new file mode 100644 index 0000000000..a22248d76a Binary files /dev/null and b/tests/auto/gui/image/qicoimageformat/icons/masked/32bpp.ico differ diff --git a/tests/auto/gui/image/qicoimageformat/icons/masked/32bpp.png b/tests/auto/gui/image/qicoimageformat/icons/masked/32bpp.png new file mode 100644 index 0000000000..a6ceac73fa Binary files /dev/null and b/tests/auto/gui/image/qicoimageformat/icons/masked/32bpp.png differ diff --git a/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp b/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp index 47bfb5bca5..c420489e3c 100644 --- a/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp +++ b/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp @@ -27,6 +27,8 @@ private slots: void pngCompression(); void write_data(); void write(); + void icoMask_data(); + void icoMask(); private: QString m_IconPath; @@ -319,6 +321,33 @@ void tst_QIcoImageFormat::write() } } +void tst_QIcoImageFormat::icoMask_data() +{ + QTest::addColumn("inFile"); + QTest::addColumn("outFile"); + + QTest::newRow("24bpp") << "masked/24bpp.ico" << "masked/24bpp.png"; + QTest::newRow("32bpp") << "masked/32bpp.ico" << "masked/32bpp.png"; +} + +void tst_QIcoImageFormat::icoMask() +{ + QFETCH(QString, inFile); + QFETCH(QString, outFile); + + QImage inImage; + QImageReader inReader(m_IconPath + QLatin1Char('/') + inFile); + inReader.read(&inImage); + + QImage outImage; + QImageReader outReader(m_IconPath + QLatin1Char('/') + outFile); + outReader.read(&outImage); + outImage.setColorSpace(inImage.colorSpace()); + outImage = outImage.convertToFormat(inImage.format()); + + QCOMPARE(inImage, outImage); +} + QTEST_MAIN(tst_QIcoImageFormat) #include "tst_qicoimageformat.moc"