- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- File List
- File Members

# qimageiohandler.h

Go to the documentation of this file.

    00001 /****************************************************************************
    00002 **
    00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    00004 ** All rights reserved.
    00005 ** Contact: Nokia Corporation (qt-info@nokia.com)
    00006 **
    00007 ** This file is part of the QtGui module of the Qt Toolkit.
    00008 **
    00009 ** $QT_BEGIN_LICENSE:LGPL$
    00010 ** Commercial Usage
    00011 ** Licensees holding valid Qt Commercial licenses may use this file in
    00012 ** accordance with the Qt Commercial License Agreement provided with the
    00013 ** Software or, alternatively, in accordance with the terms contained in
    00014 ** a written agreement between you and Nokia.
    00015 **
    00016 ** GNU Lesser General Public License Usage
    00017 ** Alternatively, this file may be used under the terms of the GNU Lesser
    00018 ** General Public License version 2.1 as published by the Free Software
    00019 ** Foundation and appearing in the file LICENSE.LGPL included in the
    00020 ** packaging of this file.  Please review the following information to
    00021 ** ensure the GNU Lesser General Public License version 2.1 requirements
    00022 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    00023 **
    00024 ** In addition, as a special exception, Nokia gives you certain additional
    00025 ** rights.  These rights are described in the Nokia Qt LGPL Exception
    00026 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this module.
    00027 **
    00028 ** GNU General Public License Usage
    00029 ** Alternatively, this file may be used under the terms of the GNU
    00030 ** General Public License version 3.0 as published by the Free Software
    00031 ** Foundation and appearing in the file LICENSE.GPL included in the
    00032 ** packaging of this file.  Please review the following information to
    00033 ** ensure the GNU General Public License version 3.0 requirements will be
    00034 ** met: http://www.gnu.org/copyleft/gpl.html.
    00035 **
    00036 ** If you have questions regarding the use of this file, please contact
    00037 ** Nokia at qt-info@nokia.com.
    00038 ** $QT_END_LICENSE$
    00039 **
    00040 ****************************************************************************/
    00041
    00042 #ifndef QIMAGEIOHANDLER_H
    00043 #define QIMAGEIOHANDLER_H
    00044
    00045 #include <QtCore/qplugin.h>
    00046 #include <QtCore/qfactoryinterface.h>
    00047 #include <QtCore/qscopedpointer.h>
    00048
    00049 QT_BEGIN_HEADER
    00050
    00051 QT_BEGIN_NAMESPACE
    00052
    00053 QT_MODULE(Gui)
    00054
    00055 class QImage;
    00056 class QRect;
    00057 class QSize;
    00058 class QVariant;
    00059
    00060 class QImageIOHandlerPrivate;
    00061 class Q_GUI_EXPORT QImageIOHandler
    00062 {
    00063     Q_DECLARE_PRIVATE(QImageIOHandler)
    00064 public:
    00065     QImageIOHandler();
    00066     virtual ~QImageIOHandler();
    00067
    00068     void setDevice(QIODevice *device);
    00069     QIODevice *device() const;
    00070
    00071     void setFormat(const QByteArray &format);
    00072     void setFormat(const QByteArray &format) const;
    00073     QByteArray format() const;
    00074
    00075     virtual QByteArray name() const;
    00076
    00077     virtual bool canRead() const = 0;
    00078     virtual bool read(QImage *image) = 0;
    00079     virtual bool write(const QImage &image);
    00080
    00081     enum ImageOption {
    00082         Size,
    00083         ClipRect,
    00084         Description,
    00085         ScaledClipRect,
    00086         ScaledSize,
    00087         CompressionRatio,
    00088         Gamma,
    00089         Quality,
    00090         Name,
    00091         SubType,
    00092         IncrementalReading,
    00093         Endianness,
    00094         Animation,
    00095         BackgroundColor,
    00096         ImageFormat
    00097     };
    00098     virtual QVariant option(ImageOption option) const;
    00099     virtual void setOption(ImageOption option, const QVariant &value);
    00100     virtual bool supportsOption(ImageOption option) const;
    00101
    00102     // incremental loading
    00103     virtual bool jumpToNextImage();
    00104     virtual bool jumpToImage(int imageNumber);
    00105     virtual int loopCount() const;
    00106     virtual int imageCount() const;
    00107     virtual int nextImageDelay() const;
    00108     virtual int currentImageNumber() const;
    00109     virtual QRect currentImageRect() const;
    00110
    00111 protected:
    00112     QImageIOHandler(QImageIOHandlerPrivate &dd);
    00113     QScopedPointer<QImageIOHandlerPrivate> d_ptr;
    00114 private:
    00115     Q_DISABLE_COPY(QImageIOHandler)
    00116 };
    00117
    00118 struct Q_GUI_EXPORT QImageIOHandlerFactoryInterface : public QFactoryInterface
    00119 {
    00120     virtual QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const = 0;
    00121 };
    00122
    00123 #define QImageIOHandlerFactoryInterface_iid "com.trolltech.Qt.QImageIOHandlerFactoryInterface"
    00124 Q_DECLARE_INTERFACE(QImageIOHandlerFactoryInterface, QImageIOHandlerFactoryInterface_iid)
    00125
    00126 class Q_GUI_EXPORT QImageIOPlugin : public QObject, public QImageIOHandlerFactoryInterface
    00127 {
    00128     Q_OBJECT
    00129     Q_INTERFACES(QImageIOHandlerFactoryInterface:QFactoryInterface)
    00130 public:
    00131     explicit QImageIOPlugin(QObject *parent = 0);
    00132     virtual ~QImageIOPlugin();
    00133
    00134     enum Capability {
    00135         CanRead = 0x1,
    00136         CanWrite = 0x2,
    00137         CanReadIncremental = 0x4
    00138     };
    00139     Q_DECLARE_FLAGS(Capabilities, Capability)
    00140
    00141     virtual Capabilities capabilities(QIODevice *device, const QByteArray &format) const = 0;
    00142     virtual QStringList keys() const = 0;
    00143     virtual QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const = 0;
    00144 };
    00145
    00146 Q_DECLARE_OPERATORS_FOR_FLAGS(QImageIOPlugin::Capabilities)
    00147
    00148 QT_END_NAMESPACE
    00149
    00150 QT_END_HEADER
    00151
    00152 #endif // QIMAGEIOHANDLER_H