From a4897c224a7f5e9814a683deb3073896171c276d Mon Sep 17 00:00:00 2001 From: Serge Lysenko Date: Mon, 14 Sep 2015 13:17:05 +0300 Subject: Implement the QImageIOHandler::ImageFormat option for ico files. We need a method to check image format of .ico with QImageReader loader. That is very useful to filter out low resolution icons. Change-Id: I2dfe3aa49cbc1e05836be846ae3da30786b98ff4 Reviewed-by: Friedemann Kleint --- src/plugins/imageformats/ico/qicohandler.cpp | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'src/plugins/imageformats/ico') diff --git a/src/plugins/imageformats/ico/qicohandler.cpp b/src/plugins/imageformats/ico/qicohandler.cpp index 6d2c06c9c8..b9b51130b5 100644 --- a/src/plugins/imageformats/ico/qicohandler.cpp +++ b/src/plugins/imageformats/ico/qicohandler.cpp @@ -779,11 +779,29 @@ QtIcoHandler::~QtIcoHandler() QVariant QtIcoHandler::option(ImageOption option) const { - if (option == Size) { + if (option == Size || option == ImageFormat) { ICONDIRENTRY iconEntry; if (m_pICOReader->readIconEntry(m_currentIconIndex, &iconEntry)) { - return QSize(iconEntry.bWidth ? iconEntry.bWidth : 256, - iconEntry.bHeight ? iconEntry.bHeight : 256); + switch (option) { + case Size: + return QSize(iconEntry.bWidth ? iconEntry.bWidth : 256, + iconEntry.bHeight ? iconEntry.bHeight : 256); + + case ImageFormat: + switch (iconEntry.wBitCount) { + case 2: + return QImage::Format_Mono; + case 24: + return QImage::Format_RGB32; + case 32: + return QImage::Format_ARGB32; + default: + return QImage::Format_Indexed8; + } + break; + default: + break; + } } } return QVariant(); @@ -791,7 +809,7 @@ QVariant QtIcoHandler::option(ImageOption option) const bool QtIcoHandler::supportsOption(ImageOption option) const { - return option == Size; + return (option == Size || option == ImageFormat); } /*! -- cgit v1.2.3