Qt 4.8
qimageiohandler.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QIMAGEIOHANDLER_H
43 #define QIMAGEIOHANDLER_H
44 
45 #include <QtCore/qplugin.h>
46 #include <QtCore/qfactoryinterface.h>
47 #include <QtCore/qscopedpointer.h>
48 
50 
52 
53 QT_MODULE(Gui)
54 
55 class QImage;
56 class QRect;
57 class QSize;
58 class QVariant;
59 
62 {
64 public:
66  virtual ~QImageIOHandler();
67 
68  void setDevice(QIODevice *device);
69  QIODevice *device() const;
70 
71  void setFormat(const QByteArray &format);
72  void setFormat(const QByteArray &format) const;
73  QByteArray format() const;
74 
75  virtual QByteArray name() const;
76 
77  virtual bool canRead() const = 0;
78  virtual bool read(QImage *image) = 0;
79  virtual bool write(const QImage &image);
80 
81  enum ImageOption {
96  ImageFormat
97  };
98  virtual QVariant option(ImageOption option) const;
99  virtual void setOption(ImageOption option, const QVariant &value);
100  virtual bool supportsOption(ImageOption option) const;
101 
102  // incremental loading
103  virtual bool jumpToNextImage();
104  virtual bool jumpToImage(int imageNumber);
105  virtual int loopCount() const;
106  virtual int imageCount() const;
107  virtual int nextImageDelay() const;
108  virtual int currentImageNumber() const;
109  virtual QRect currentImageRect() const;
110 
111 protected:
114 private:
116 };
117 
119 {
120  virtual QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const = 0;
121 };
122 
123 #define QImageIOHandlerFactoryInterface_iid "com.trolltech.Qt.QImageIOHandlerFactoryInterface"
125 
127 {
128  Q_OBJECT
129  Q_INTERFACES(QImageIOHandlerFactoryInterface:QFactoryInterface)
130 public:
131  explicit QImageIOPlugin(QObject *parent = 0);
132  virtual ~QImageIOPlugin();
133 
134  enum Capability {
135  CanRead = 0x1,
136  CanWrite = 0x2,
137  CanReadIncremental = 0x4
138  };
139  Q_DECLARE_FLAGS(Capabilities, Capability)
140 
141  virtual Capabilities capabilities(QIODevice *device, const QByteArray &format) const = 0;
142  virtual QStringList keys() const = 0;
143  virtual QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const = 0;
144 };
145 
146 Q_DECLARE_OPERATORS_FOR_FLAGS(QImageIOPlugin::Capabilities)
147 
149 
151 
152 #endif // QIMAGEIOHANDLER_H
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
#define QImageIOHandlerFactoryInterface_iid
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
#define QT_MODULE(x)
Definition: qglobal.h:2783
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
#define Q_DECLARE_FLAGS(Flags, Enum)
The Q_DECLARE_FLAGS() macro expands to.
Definition: qglobal.h:2348
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
static Expression::Ptr create(Expression *const expr, const YYLTYPE &sourceLocator, const ParserContext *const parseInfo)
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
Definition: qglobal.h:2523
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define Q_DECLARE_INTERFACE(IFace, IId)
Definition: qobject.h:397
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
Capability
This enum describes the capabilities of a QImageIOPlugin.
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
The Q_DECLARE_OPERATORS_FOR_FLAGS() macro declares global operator|() functions for Flags...
Definition: qglobal.h:2355
ImageOption
This enum describes the different options supported by QImageIOHandler.
const char * name
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
handler setDevice(device)
The QImageIOHandlerFactoryInterface class provides the factory interface for QImageIOPlugin.
#define Q_OBJECT
Definition: qobjectdefs.h:157
virtual QStringList keys() const =0
The QImageIOPlugin class defines an interface for writing an image format plugin. ...
The QImageIOHandler class defines the common image I/O interface for all image formats in Qt...
QScopedPointer< QImageIOHandlerPrivate > d_ptr
#define Q_INTERFACES(x)
This macro tells Qt which interfaces the class implements.
Definition: qobjectdefs.h:79
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
#define Q_DECLARE_PRIVATE(Class)
Definition: qglobal.h:2467
#define class
The QIODevice class is the base interface class of all I/O devices in Qt.
Definition: qiodevice.h:66
#define QT_END_HEADER
Definition: qglobal.h:137