diff options
author | Kai Uwe Broulik <[email protected]> | 2025-06-06 16:27:23 +0200 |
---|---|---|
committer | Kai Uwe Broulik <[email protected]> | 2025-07-09 18:56:54 +0200 |
commit | 3051beb7755e324c927cbeeb19f610b89f7f0436 (patch) | |
tree | fae0c2022f9f22153f7b680c03b16c0709ad2316 | |
parent | 3f953283687353c6cb73e2e8bfedc3097604a57d (diff) |
Qt handles ICONDIRENTRY having a wBitCount of zero by using
BITMAPINFOHEADER.biBitCount. However, it does not report that
value through _q_icoOrigDepth. This makes the QIcon unable
to pick the highest quality image for some ICO files.
Pick-to: 6.10 6.9 6.8
Change-Id: Id73a1e480214c9d782e6122101728c2bc5dbf9e7
Reviewed-by: Eirik Aavitsland <[email protected]>
-rw-r--r-- | src/plugins/imageformats/ico/qicohandler.cpp | 2 | ||||
-rw-r--r-- | tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp | 36 |
2 files changed, 37 insertions, 1 deletions
diff --git a/src/plugins/imageformats/ico/qicohandler.cpp b/src/plugins/imageformats/ico/qicohandler.cpp index b5113578dd2..03677107d7d 100644 --- a/src/plugins/imageformats/ico/qicohandler.cpp +++ b/src/plugins/imageformats/ico/qicohandler.cpp @@ -518,7 +518,7 @@ QImage ICOReader::iconAt(int index) } } } - img.setText(QLatin1String(icoOrigDepthKey), QString::number(iconEntry.wBitCount)); + img.setText(QLatin1String(icoOrigDepthKey), QString::number(icoAttrib.nbits)); } } } diff --git a/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp b/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp index 36cf8ac8fd8..18fe43fbcea 100644 --- a/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp +++ b/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp @@ -35,6 +35,8 @@ private slots: void write(); void icoMask_data(); void icoMask(); + void origBitDepth_data(); + void origBitDepth(); private: QString m_IconPath; @@ -354,6 +356,40 @@ void tst_QIcoImageFormat::icoMask() QCOMPARE(inImage, outImage); } +void tst_QIcoImageFormat::origBitDepth_data() +{ + QTest::addColumn<QString>("file"); + QTest::addColumn<QList<int>>("origBitDepths"); + + QTest::newRow("35FLOPPY") << "35FLOPPY.ICO" << QList<int>{4}; + QTest::newRow("abcardWindow") << "abcardWindow.ico" << QList<int>{8}; + QTest::newRow("AddPerf") << "AddPerfMon.ico" << QList<int>{4}; + QTest::newRow("App") << "App.ico" << QList<int>{4}; + QTest::newRow("Obj_N2_Internal_Mem") << "Obj_N2_Internal_Mem.ico" << QList<int>{4, 8, 32}; + QTest::newRow("Qt") << "Qt.ico" << QList<int>{32}; + QTest::newRow("semitransparent") << "semitransparent.ico" << QList<int>{4}; + QTest::newRow("Status_Play") << "Status_Play.ico" << QList<int>{4, 8, 32}; + QTest::newRow("TIMER01") << "TIMER01.ICO" << QList<int>{4}; + QTest::newRow("trolltechlogo_tiny") << "trolltechlogo_tiny.ico" << QList<int>{8}; + QTest::newRow("WORLD") << "WORLD.ico" << QList<int>{8, 4, 4}; + QTest::newRow("yellow") << "yellow.cur" << QList<int>{32}; +} + +void tst_QIcoImageFormat::origBitDepth() +{ + QFETCH(QString, file); + QFETCH(QList<int>, origBitDepths); + + QImage image; + QImageReader reader(m_IconPath + QLatin1String("/valid/") + file); + + for (int depth : origBitDepths) { + reader.read(&image); + QCOMPARE(image.text("_q_icoOrigDepth").toInt(), depth); + reader.jumpToNextImage(); + } +} + QTEST_MAIN(tst_QIcoImageFormat) #include "tst_qicoimageformat.moc" |