From 1768c145e07417a53abeb18bebda085b21d8f1d5 Mon Sep 17 00:00:00 2001 From: miniak Date: Mon, 20 Jul 2009 18:47:37 +0200 Subject: Partial fix for Qt issue #244648 - QtIcoHandler does not support large & Vista PNG format icons Merge-request: 431 Reviewed-by: Joerg Bornemann --- src/plugins/imageformats/ico/qicohandler.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/plugins/imageformats/ico/qicohandler.cpp b/src/plugins/imageformats/ico/qicohandler.cpp index 43e35c0..c9e04a4 100644 --- a/src/plugins/imageformats/ico/qicohandler.cpp +++ b/src/plugins/imageformats/ico/qicohandler.cpp @@ -522,6 +522,18 @@ QImage ICOReader::iconAt(int index) ICONDIRENTRY iconEntry; if (readIconEntry(index, &iconEntry)) { + static const uchar pngMagicData[] = { 137, 80, 78, 71, 13, 10, 26, 10 }; + + iod->seek(iconEntry.dwImageOffset); + + const QByteArray pngMagic = QByteArray::fromRawData((char*)pngMagicData, sizeof(pngMagicData)); + const bool isPngImage = (iod->read(pngMagic.size()) == pngMagic); + + if (isPngImage) { + iod->seek(iconEntry.dwImageOffset); + return QImage::fromData(iod->read(iconEntry.dwBytesInRes), "png"); + } + BMP_INFOHDR header; if (readBMPHeader(iconEntry.dwImageOffset, &header)) { icoAttrib.nbits = header.biBitCount ? header.biBitCount : iconEntry.wBitCount; -- cgit v0.12