summaryrefslogtreecommitdiff
path: root/src/plugins/imageformats/mng
diff options
context:
space:
mode:
authorKent Hansen <kent.hansen@nokia.com>2012-01-23 11:57:17 +0100
committerQt by Nokia <qt-info@nokia.com>2012-01-25 09:38:12 +0100
commitc64ae4f1615f0fe9322ffcb09e50e360068fd11a (patch)
tree2e6bec67c939e226e0efa46f966b5e990aa8abb2 /src/plugins/imageformats/mng
parent2564c403a1fbcf110475b071c3b60eca1991a455 (diff)
downloadqtimageformats-c64ae4f1615f0fe9322ffcb09e50e360068fd11a.tar.gz
Long live the qtimageformats module
This module contains plugins for image formats that aren't part of the "core" (qtbase) offering, starting with mng. Task-number: QTBUG-21869 Change-Id: I85e51ed6f84c07419b1676f9def234c36f10141f Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: aavit <qt_aavit@ovi.com>
Diffstat (limited to 'src/plugins/imageformats/mng')
-rw-r--r--src/plugins/imageformats/mng/main.cpp98
-rw-r--r--src/plugins/imageformats/mng/mng.pro20
-rw-r--r--src/plugins/imageformats/mng/qmnghandler.cpp497
-rw-r--r--src/plugins/imageformats/mng/qmnghandler.pri10
-rw-r--r--src/plugins/imageformats/mng/qmnghandler_p.h83
5 files changed, 708 insertions, 0 deletions
diff --git a/src/plugins/imageformats/mng/main.cpp b/src/plugins/imageformats/mng/main.cpp
new file mode 100644
index 0000000..e5e6250
--- /dev/null
+++ b/src/plugins/imageformats/mng/main.cpp
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qimageiohandler.h>
+#include <qstringlist.h>
+
+#ifndef QT_NO_IMAGEFORMATPLUGIN
+
+#ifdef QT_NO_IMAGEFORMAT_MNG
+#undef QT_NO_IMAGEFORMAT_MNG
+#endif
+#include <qmnghandler_p.h>
+
+#include <qiodevice.h>
+#include <qbytearray.h>
+
+QT_BEGIN_NAMESPACE
+
+class QMngPlugin : public QImageIOPlugin
+{
+ public:
+ QStringList keys() const;
+ Capabilities capabilities(QIODevice *device, const QByteArray &format) const;
+ QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const;
+};
+
+QStringList QMngPlugin::keys() const
+{
+ return QStringList() << QLatin1String("mng");
+}
+
+QImageIOPlugin::Capabilities QMngPlugin::capabilities(QIODevice *device, const QByteArray &format) const
+{
+ if (format == "mng")
+ return Capabilities(CanRead);
+ if (!format.isEmpty())
+ return 0;
+ if (!device->isOpen())
+ return 0;
+
+ Capabilities cap;
+ if (device->isReadable() && QMngHandler::canRead(device))
+ cap |= CanRead;
+ return cap;
+}
+
+QImageIOHandler *QMngPlugin::create(QIODevice *device, const QByteArray &format) const
+{
+ QMngHandler *hand = new QMngHandler();
+ hand->setDevice(device);
+ hand->setFormat(format);
+ return hand;
+}
+
+Q_EXPORT_STATIC_PLUGIN(QMngPlugin)
+Q_EXPORT_PLUGIN2(qmng, QMngPlugin)
+
+QT_END_NAMESPACE
+
+#endif // !QT_NO_IMAGEFORMATPLUGIN
diff --git a/src/plugins/imageformats/mng/mng.pro b/src/plugins/imageformats/mng/mng.pro
new file mode 100644
index 0000000..1bac008
--- /dev/null
+++ b/src/plugins/imageformats/mng/mng.pro
@@ -0,0 +1,20 @@
+TARGET = qmng
+load(qt_plugin)
+
+# QTDIR_build:REQUIRES = "!contains(QT_CONFIG, no-mng)"
+
+HEADERS += qmnghandler_p.h
+SOURCES += qmnghandler.cpp
+contains(QT_CONFIG, system-mng) {
+ if(unix|win32-g++*):LIBS += -lmng
+ else:win32: LIBS += libmng.lib
+} else {
+ include($$PWD/../../../3rdparty/libmng.pri)
+ *-g++*: QMAKE_CFLAGS_WARN_ON += -Wno-unused-parameter
+}
+
+SOURCES += main.cpp
+
+DESTDIR = $$QT.gui.plugins/imageformats
+target.path += $$[QT_INSTALL_PLUGINS]/imageformats
+INSTALLS += target
diff --git a/src/plugins/imageformats/mng/qmnghandler.cpp b/src/plugins/imageformats/mng/qmnghandler.cpp
new file mode 100644
index 0000000..dfea57f
--- /dev/null
+++ b/src/plugins/imageformats/mng/qmnghandler.cpp
@@ -0,0 +1,497 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qmnghandler_p.h"
+
+#include "qimage.h"
+#include "qvariant.h"
+#include "qcolor.h"
+
+#define MNG_USE_SO
+#include <libmng.h>
+
+QT_BEGIN_NAMESPACE
+
+class QMngHandlerPrivate
+{
+ Q_DECLARE_PUBLIC(QMngHandler)
+ public:
+ bool haveReadNone;
+ bool haveReadAll;
+ mng_handle hMNG;
+ QImage image;
+ int elapsed;
+ int nextDelay;
+ int iterCount;
+ int frameIndex;
+ int nextIndex;
+ int frameCount;
+ mng_uint32 iStyle;
+ mng_bool readData(mng_ptr pBuf, mng_uint32 iSize, mng_uint32p pRead);
+ mng_bool writeData(mng_ptr pBuf, mng_uint32 iSize, mng_uint32p pWritten);
+ mng_bool processHeader(mng_uint32 iWidth, mng_uint32 iHeight);
+ QMngHandlerPrivate(QMngHandler *q_ptr);
+ ~QMngHandlerPrivate();
+ bool getNextImage(QImage *result);
+ bool writeImage(const QImage &image);
+ int currentImageNumber() const;
+ int imageCount() const;
+ bool jumpToImage(int imageNumber);
+ bool jumpToNextImage();
+ int nextImageDelay() const;
+ bool setBackgroundColor(const QColor &color);
+ QColor backgroundColor() const;
+ QMngHandler *q_ptr;
+};
+
+static mng_bool myerror(mng_handle /*hMNG*/,
+ mng_int32 iErrorcode,
+ mng_int8 /*iSeverity*/,
+ mng_chunkid iChunkname,
+ mng_uint32 /*iChunkseq*/,
+ mng_int32 iExtra1,
+ mng_int32 iExtra2,
+ mng_pchar zErrortext)
+{
+ qWarning("MNG error %d: %s; chunk %c%c%c%c; subcode %d:%d",
+ iErrorcode,zErrortext,
+ (iChunkname>>24)&0xff,
+ (iChunkname>>16)&0xff,
+ (iChunkname>>8)&0xff,
+ (iChunkname>>0)&0xff,
+ iExtra1,iExtra2);
+ return TRUE;
+}
+
+static mng_ptr myalloc(mng_size_t iSize)
+{
+#if defined(Q_OS_WINCE)
+ mng_ptr ptr = malloc(iSize);
+ memset(ptr, 0, iSize);
+ return ptr;
+#else
+ return (mng_ptr)calloc(1, iSize);
+#endif
+}
+
+static void myfree(mng_ptr pPtr, mng_size_t /*iSize*/)
+{
+ free(pPtr);
+}
+
+static mng_bool myopenstream(mng_handle)
+{
+ return MNG_TRUE;
+}
+
+static mng_bool myclosestream(mng_handle hMNG)
+{
+ QMngHandlerPrivate *pMydata = reinterpret_cast<QMngHandlerPrivate *>(mng_get_userdata(hMNG));
+ pMydata->haveReadAll = true;
+ return MNG_TRUE;
+}
+
+static mng_bool myreaddata(mng_handle hMNG,
+ mng_ptr pBuf,
+ mng_uint32 iSize,
+ mng_uint32p pRead)
+{
+ QMngHandlerPrivate *pMydata = reinterpret_cast<QMngHandlerPrivate *>(mng_get_userdata(hMNG));
+ return pMydata->readData(pBuf, iSize, pRead);
+}
+
+static mng_bool mywritedata(mng_handle hMNG,
+ mng_ptr pBuf,
+ mng_uint32 iSize,
+ mng_uint32p pWritten)
+{
+ QMngHandlerPrivate *pMydata = reinterpret_cast<QMngHandlerPrivate *>(mng_get_userdata(hMNG));
+ return pMydata->writeData(pBuf, iSize, pWritten);
+}
+
+static mng_bool myprocessheader(mng_handle hMNG,
+ mng_uint32 iWidth,
+ mng_uint32 iHeight)
+{
+ QMngHandlerPrivate *pMydata = reinterpret_cast<QMngHandlerPrivate *>(mng_get_userdata(hMNG));
+ return pMydata->processHeader(iWidth, iHeight);
+}
+
+static mng_ptr mygetcanvasline(mng_handle hMNG,
+ mng_uint32 iLinenr)
+{
+ QMngHandlerPrivate *pMydata = reinterpret_cast<QMngHandlerPrivate *>(mng_get_userdata(hMNG));
+ return (mng_ptr)pMydata->image.scanLine(iLinenr);
+}
+
+static mng_bool myrefresh(mng_handle /*hMNG*/,
+ mng_uint32 /*iX*/,
+ mng_uint32 /*iY*/,
+ mng_uint32 /*iWidth*/,
+ mng_uint32 /*iHeight*/)
+{
+ return MNG_TRUE;
+}
+
+static mng_uint32 mygettickcount(mng_handle hMNG)
+{
+ QMngHandlerPrivate *pMydata = reinterpret_cast<QMngHandlerPrivate *>(mng_get_userdata(hMNG));
+ return pMydata->elapsed++;
+}
+
+static mng_bool mysettimer(mng_handle hMNG,
+ mng_uint32 iMsecs)
+{
+ QMngHandlerPrivate *pMydata = reinterpret_cast<QMngHandlerPrivate *>(mng_get_userdata(hMNG));
+ pMydata->elapsed += iMsecs;
+ pMydata->nextDelay = iMsecs;
+ return MNG_TRUE;
+}
+
+static mng_bool myprocessterm(mng_handle hMNG,
+ mng_uint8 iTermaction,
+ mng_uint8 /*iIteraction*/,
+ mng_uint32 /*iDelay*/,
+ mng_uint32 iItermax)
+{
+ QMngHandlerPrivate *pMydata = reinterpret_cast<QMngHandlerPrivate *>(mng_get_userdata(hMNG));
+ if (iTermaction == 3)
+ pMydata->iterCount = iItermax;
+ return MNG_TRUE;
+}
+
+static mng_bool mytrace(mng_handle,
+ mng_int32 iFuncnr,
+ mng_int32 iFuncseq,
+ mng_pchar zFuncname)
+{
+ qDebug("mng trace: iFuncnr: %d iFuncseq: %d zFuncname: %s", iFuncnr, iFuncseq, zFuncname);
+ return MNG_TRUE;
+}
+
+QMngHandlerPrivate::QMngHandlerPrivate(QMngHandler *q_ptr)
+ : haveReadNone(true), haveReadAll(false), elapsed(0), nextDelay(0), iterCount(1),
+ frameIndex(-1), nextIndex(0), frameCount(0), q_ptr(q_ptr)
+{
+ iStyle = (QSysInfo::ByteOrder == QSysInfo::LittleEndian) ? MNG_CANVAS_BGRA8 : MNG_CANVAS_ARGB8;
+ // Initialize libmng
+ hMNG = mng_initialize((mng_ptr)this, myalloc, myfree, mytrace);
+ if (hMNG) {
+ // Set callback functions
+ mng_setcb_errorproc(hMNG, myerror);
+ mng_setcb_openstream(hMNG, myopenstream);
+ mng_setcb_closestream(hMNG, myclosestream);
+ mng_setcb_readdata(hMNG, myreaddata);
+ mng_setcb_writedata(hMNG, mywritedata);
+ mng_setcb_processheader(hMNG, myprocessheader);
+ mng_setcb_getcanvasline(hMNG, mygetcanvasline);
+ mng_setcb_refresh(hMNG, myrefresh);
+ mng_setcb_gettickcount(hMNG, mygettickcount);
+ mng_setcb_settimer(hMNG, mysettimer);
+ mng_setcb_processterm(hMNG, myprocessterm);
+ mng_set_doprogressive(hMNG, MNG_FALSE);
+ mng_set_suspensionmode(hMNG, MNG_TRUE);
+ }
+}
+
+QMngHandlerPrivate::~QMngHandlerPrivate()
+{
+ mng_cleanup(&hMNG);
+}
+
+mng_bool QMngHandlerPrivate::readData(mng_ptr pBuf, mng_uint32 iSize, mng_uint32p pRead)
+{
+ Q_Q(QMngHandler);
+ *pRead = q->device()->read((char *)pBuf, iSize);
+ return (*pRead > 0) ? MNG_TRUE : MNG_FALSE;
+}
+
+mng_bool QMngHandlerPrivate::writeData(mng_ptr pBuf, mng_uint32 iSize, mng_uint32p pWritten)
+{
+ Q_Q(QMngHandler);
+ *pWritten = q->device()->write((char *)pBuf, iSize);
+ return MNG_TRUE;
+}
+
+mng_bool QMngHandlerPrivate::processHeader(mng_uint32 iWidth, mng_uint32 iHeight)
+{
+ if (mng_set_canvasstyle(hMNG, iStyle) != MNG_NOERROR)
+ return MNG_FALSE;
+ image = QImage(iWidth, iHeight, QImage::Format_ARGB32);
+ image.fill(0);
+ return MNG_TRUE;
+}
+
+bool QMngHandlerPrivate::getNextImage(QImage *result)
+{
+ mng_retcode ret;
+ if (haveReadNone) {
+ haveReadNone = false;
+ ret = mng_readdisplay(hMNG);
+ } else {
+ ret = mng_display_resume(hMNG);
+ }
+ if ((MNG_NOERROR == ret) || (MNG_NEEDTIMERWAIT == ret)) {
+ *result = image;
+ frameIndex = nextIndex++;
+ if (haveReadAll && (frameCount == 0))
+ frameCount = nextIndex;
+ return true;
+ }
+ return false;
+}
+
+bool QMngHandlerPrivate::writeImage(const QImage &image)
+{
+ mng_reset(hMNG);
+ if (mng_create(hMNG) != MNG_NOERROR)
+ return false;
+
+ this->image = image.convertToFormat(QImage::Format_ARGB32);
+ int w = image.width();
+ int h = image.height();
+
+ if (
+ // width, height, ticks, layercount, framecount, playtime, simplicity
+ (mng_putchunk_mhdr(hMNG, w, h, 1000, 0, 0, 0, 7) == MNG_NOERROR) &&
+ // termination_action, action_after_iterations, delay, iteration_max
+ (mng_putchunk_term(hMNG, 3, 0, 1, 0x7FFFFFFF) == MNG_NOERROR) &&
+ // width, height, bitdepth, colortype, compression, filter, interlace
+ (mng_putchunk_ihdr(hMNG, w, h, 8, 6, 0, 0, 0) == MNG_NOERROR) &&
+ // width, height, colortype, bitdepth, compression, filter, interlace, canvasstyle, getcanvasline
+ (mng_putimgdata_ihdr(hMNG, w, h, 6, 8, 0, 0, 0, iStyle, mygetcanvasline) == MNG_NOERROR) &&
+ (mng_putchunk_iend(hMNG) == MNG_NOERROR) &&
+ (mng_putchunk_mend(hMNG) == MNG_NOERROR) &&
+ (mng_write(hMNG) == MNG_NOERROR)
+ )
+ return true;
+ return false;
+}
+
+int QMngHandlerPrivate::currentImageNumber() const
+{
+// return mng_get_currentframe(hMNG) % imageCount(); not implemented, apparently
+ return frameIndex;
+}
+
+int QMngHandlerPrivate::imageCount() const
+{
+// return mng_get_totalframes(hMNG); not implemented, apparently
+ if (haveReadAll)
+ return frameCount;
+ return 0; // Don't know
+}
+
+bool QMngHandlerPrivate::jumpToImage(int imageNumber)
+{
+ if (imageNumber == nextIndex)
+ return true;
+
+ if ((imageNumber == 0) && haveReadAll && (nextIndex == frameCount)) {
+ // Loop!
+ nextIndex = 0;
+ return true;
+ }
+ if (mng_display_freeze(hMNG) == MNG_NOERROR) {
+ if (mng_display_goframe(hMNG, imageNumber) == MNG_NOERROR) {
+ nextIndex = imageNumber;
+ return true;
+ }
+ }
+ return false;
+}
+
+bool QMngHandlerPrivate::jumpToNextImage()
+{
+ return jumpToImage((currentImageNumber()+1) % imageCount());
+}
+
+int QMngHandlerPrivate::nextImageDelay() const
+{
+ return nextDelay;
+}
+
+bool QMngHandlerPrivate::setBackgroundColor(const QColor &color)
+{
+ mng_uint16 iRed = (mng_uint16)(color.red() << 8);
+ mng_uint16 iBlue = (mng_uint16)(color.blue() << 8);
+ mng_uint16 iGreen = (mng_uint16)(color.green() << 8);
+ return (mng_set_bgcolor(hMNG, iRed, iBlue, iGreen) == MNG_NOERROR);
+}
+
+QColor QMngHandlerPrivate::backgroundColor() const
+{
+ mng_uint16 iRed;
+ mng_uint16 iBlue;
+ mng_uint16 iGreen;
+ if (mng_get_bgcolor(hMNG, &iRed, &iBlue, &iGreen) == MNG_NOERROR)
+ return QColor((iRed >> 8) & 0xFF, (iGreen >> 8) & 0xFF, (iBlue >> 8) & 0xFF);
+ return QColor();
+}
+
+QMngHandler::QMngHandler()
+ : d_ptr(new QMngHandlerPrivate(this))
+{
+}
+
+QMngHandler::~QMngHandler()
+{
+}
+
+/*! \reimp */
+bool QMngHandler::canRead() const
+{
+ Q_D(const QMngHandler);
+ if ((!d->haveReadNone
+ && (!d->haveReadAll || (d->haveReadAll && (d->nextIndex < d->frameCount))))
+ || canRead(device()))
+ {
+ setFormat("mng");
+ return true;
+ }
+ return false;
+}
+
+/*! \internal */
+bool QMngHandler::canRead(QIODevice *device)
+{
+ if (!device) {
+ qWarning("QMngHandler::canRead() called with no device");
+ return false;
+ }
+
+ return device->peek(8) == "\x8A\x4D\x4E\x47\x0D\x0A\x1A\x0A";
+}
+
+/*! \reimp */
+QByteArray QMngHandler::name() const
+{
+ return "mng";
+}
+
+/*! \reimp */
+bool QMngHandler::read(QImage *image)
+{
+ Q_D(QMngHandler);
+ return canRead() ? d->getNextImage(image) : false;
+}
+
+/*! \reimp */
+bool QMngHandler::write(const QImage &image)
+{
+ Q_D(QMngHandler);
+ return d->writeImage(image);
+}
+
+/*! \reimp */
+int QMngHandler::currentImageNumber() const
+{
+ Q_D(const QMngHandler);
+ return d->currentImageNumber();
+}
+
+/*! \reimp */
+int QMngHandler::imageCount() const
+{
+ Q_D(const QMngHandler);
+ return d->imageCount();
+}
+
+/*! \reimp */
+bool QMngHandler::jumpToImage(int imageNumber)
+{
+ Q_D(QMngHandler);
+ return d->jumpToImage(imageNumber);
+}
+
+/*! \reimp */
+bool QMngHandler::jumpToNextImage()
+{
+ Q_D(QMngHandler);
+ return d->jumpToNextImage();
+}
+
+/*! \reimp */
+int QMngHandler::loopCount() const
+{
+ Q_D(const QMngHandler);
+ if (d->iterCount == 0x7FFFFFFF)
+ return -1; // infinite loop
+ return d->iterCount-1;
+}
+
+/*! \reimp */
+int QMngHandler::nextImageDelay() const
+{
+ Q_D(const QMngHandler);
+ return d->nextImageDelay();
+}
+
+/*! \reimp */
+QVariant QMngHandler::option(ImageOption option) const
+{
+ Q_D(const QMngHandler);
+ if (option == QImageIOHandler::Animation)
+ return true;
+ else if (option == QImageIOHandler::BackgroundColor)
+ return d->backgroundColor();
+ return QVariant();
+}
+
+/*! \reimp */
+void QMngHandler::setOption(ImageOption option, const QVariant & value)
+{
+ Q_D(QMngHandler);
+ if (option == QImageIOHandler::BackgroundColor)
+ d->setBackgroundColor(qvariant_cast<QColor>(value));
+}
+
+/*! \reimp */
+bool QMngHandler::supportsOption(ImageOption option) const
+{
+ if (option == QImageIOHandler::Animation)
+ return true;
+ else if (option == QImageIOHandler::BackgroundColor)
+ return true;
+ return false;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/imageformats/mng/qmnghandler.pri b/src/plugins/imageformats/mng/qmnghandler.pri
new file mode 100644
index 0000000..ffb98de
--- /dev/null
+++ b/src/plugins/imageformats/mng/qmnghandler.pri
@@ -0,0 +1,10 @@
+# common to plugin and built-in forms
+INCLUDEPATH *= $$PWD
+HEADERS += $$PWD/qmnghandler_p.h
+SOURCES += $$PWD/qmnghandler.cpp
+contains(QT_CONFIG, system-mng) {
+ if(unix|win32-g++*):LIBS += -lmng
+ else:win32: LIBS += libmng.lib
+} else {
+ include($$PWD/../../3rdparty/libmng.pri)
+}
diff --git a/src/plugins/imageformats/mng/qmnghandler_p.h b/src/plugins/imageformats/mng/qmnghandler_p.h
new file mode 100644
index 0000000..5376acd
--- /dev/null
+++ b/src/plugins/imageformats/mng/qmnghandler_p.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMNGHANDLER_P_H
+#define QMNGHANDLER_P_H
+
+#include <QtCore/qscopedpointer.h>
+#include <QtGui/qimageiohandler.h>
+
+QT_BEGIN_NAMESPACE
+
+class QImage;
+class QByteArray;
+class QIODevice;
+class QVariant;
+class QMngHandlerPrivate;
+
+class QMngHandler : public QImageIOHandler
+{
+ public:
+ QMngHandler();
+ ~QMngHandler();
+ virtual bool canRead() const;
+ virtual QByteArray name() const;
+ virtual bool read(QImage *image);
+ virtual bool write(const QImage &image);
+ virtual int currentImageNumber() const;
+ virtual int imageCount() const;
+ virtual bool jumpToImage(int imageNumber);
+ virtual bool jumpToNextImage();
+ virtual int loopCount() const;
+ virtual int nextImageDelay() const;
+ static bool canRead(QIODevice *device);
+ virtual QVariant option(ImageOption option) const;
+ virtual void setOption(ImageOption option, const QVariant & value);
+ virtual bool supportsOption(ImageOption option) const;
+
+ private:
+ Q_DECLARE_PRIVATE(QMngHandler)
+ QScopedPointer<QMngHandlerPrivate> d_ptr;
+};
+
+QT_END_NAMESPACE
+
+#endif // QMNGHANDLER_P_H