diff options
author | miniak <milan.burda@gmail.com> | 2009-07-20 16:47:37 (GMT) |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@trolltech.com> | 2009-07-20 16:48:49 (GMT) |
commit | 1768c145e07417a53abeb18bebda085b21d8f1d5 (patch) | |
tree | faff77060416d3474a83b719c292793b897a1b87 /src/plugins/imageformats/ico | |
parent | dc76e15214c2ad2f49bf62bc969a89438dc36ee7 (diff) | |
download | Qt-1768c145e07417a53abeb18bebda085b21d8f1d5.zip Qt-1768c145e07417a53abeb18bebda085b21d8f1d5.tar.gz Qt-1768c145e07417a53abeb18bebda085b21d8f1d5.tar.bz2 |
Partial fix for Qt issue #244648 - QtIcoHandler does not support large & Vista PNG format icons
Merge-request: 431
Reviewed-by: Joerg Bornemann <joerg.bornemann@trolltech.com>
Diffstat (limited to 'src/plugins/imageformats/ico')
-rw-r--r-- | src/plugins/imageformats/ico/qicohandler.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
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; |