summaryrefslogtreecommitdiffstats
path: root/src/plugins/imageformats/ico
diff options
context:
space:
mode:
authorSerge Lysenko <sergii.lysenko@avid.com>2015-09-14 13:17:05 +0300
committerSerge Lysenko <sergii.lysenko@avid.com>2015-09-23 12:59:29 +0000
commita4897c224a7f5e9814a683deb3073896171c276d (patch)
treeaa9c0e849a8de13aa6a357566aee2675852e70b4 /src/plugins/imageformats/ico
parenta6e2213e007c700594cc3293a7b0df3d2ebb051e (diff)
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 <Friedemann.Kleint@theqtcompany.com>
Diffstat (limited to 'src/plugins/imageformats/ico')
-rw-r--r--src/plugins/imageformats/ico/qicohandler.cpp26
1 files changed, 22 insertions, 4 deletions
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);
}
/*!