src/plugins/imageformats/ico/qicohandler.cpp
branchRCL_3
changeset 8 3f74d0d4af4c
parent 5 d3bac044e0f0
--- a/src/plugins/imageformats/ico/qicohandler.cpp	Mon Mar 15 12:43:09 2010 +0200
+++ b/src/plugins/imageformats/ico/qicohandler.cpp	Thu Apr 08 14:19:33 2010 +0300
@@ -53,6 +53,7 @@
 #include <QtGui/QImage>
 #include <QtCore/QFile>
 #include <QtCore/QBuffer>
+#include <qvariant.h>
 // These next two structs represent how the icon information is stored
 // in an ICO file.
 typedef struct
@@ -772,6 +773,29 @@
     delete m_pICOReader;
 }
 
+QVariant QtIcoHandler::option(ImageOption option) const
+{
+    if (option == Size) {
+        QIODevice *device = QImageIOHandler::device();
+        qint64 oldPos = device->pos();
+        ICONDIRENTRY iconEntry;
+        if (device->seek(oldPos + ICONDIR_SIZE + (m_currentIconIndex * ICONDIRENTRY_SIZE))) {
+            if (readIconDirEntry(device, &iconEntry)) {
+                device->seek(oldPos);
+                return QSize(iconEntry.bWidth, iconEntry.bHeight);
+            }
+        }
+        if (!device->isSequential())
+            device->seek(oldPos);
+    }
+    return QVariant();
+}
+
+bool QtIcoHandler::supportsOption(ImageOption option) const
+{
+    return option == Size;
+}
+
 /*!
  * Verifies if some values (magic bytes) are set as expected in the header of the file.
  * If the magic bytes were found, it is assumed that the QtIcoHandler can read the file.