QtGui/qimageiohandler.h Source File

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>
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 
60 class QImageIOHandlerPrivate;
61 class Q_GUI_EXPORT QImageIOHandler
62 {
63  Q_DECLARE_PRIVATE(QImageIOHandler)
64 public:
65  QImageIOHandler();
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:
112  QImageIOHandler(QImageIOHandlerPrivate &dd);
114 private:
115  Q_DISABLE_COPY(QImageIOHandler)
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 
126 class Q_GUI_EXPORT QImageIOPlugin : public QObject, public QImageIOHandlerFactoryInterface
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
#define QImageIOHandlerFactoryInterface_iid
#define QT_END_NAMESPACE
Definition: qglobal.h:128
#define QT_BEGIN_HEADER
Definition: qglobal.h:141
GLXDrawable GLXDrawable read
Definition: GLee.h:10243
GLenum GLsizei GLenum GLenum const GLvoid * image
Definition: GLee.h:882
#define QT_BEGIN_NAMESPACE
Definition: qglobal.h:127
GLenum GLsizei GLenum format
Definition: GLee.h:873
QT_BEGIN_NAMESPACE Q_DECLARE_INTERFACE(QWebKitPlatformPlugin,"com.nokia.Qt.WebKit.PlatformPlugin/1.7")
Definition: qimage.h:87
QScopedPointer< QImageIOHandlerPrivate > d_ptr
#define Q_OBJECT
Definition: qobjectdefs.h:157
GLsizei const GLfloat * value
Definition: GLee.h:1742
Definition: qrect.h:58
Definition: qsize.h:53
GLuint const GLchar * name
Definition: GLee.h:1704
#define Q_INTERFACES(x)
Definition: qobjectdefs.h:79
#define QT_END_HEADER
Definition: qglobal.h:142