1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation ([email protected])
|
---|
6 | **
|
---|
7 | ** This file is part of the QtGui module of the Qt Toolkit.
|
---|
8 | **
|
---|
9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
10 | ** Commercial Usage
|
---|
11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
14 | ** a written agreement between you and Nokia.
|
---|
15 | **
|
---|
16 | ** GNU Lesser General Public License Usage
|
---|
17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
18 | ** General Public License version 2.1 as published by the Free Software
|
---|
19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
20 | ** packaging of this file. Please review the following information to
|
---|
21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
23 | **
|
---|
24 | ** In addition, as a special exception, Nokia gives you certain additional
|
---|
25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
---|
26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
---|
27 | **
|
---|
28 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you have questions regarding the use of this file, please contact
|
---|
37 | ** Nokia at [email protected].
|
---|
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 |
|
---|
49 | QT_BEGIN_HEADER
|
---|
50 |
|
---|
51 | QT_BEGIN_NAMESPACE
|
---|
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 {
|
---|
82 | Size,
|
---|
83 | ClipRect,
|
---|
84 | Description,
|
---|
85 | ScaledClipRect,
|
---|
86 | ScaledSize,
|
---|
87 | CompressionRatio,
|
---|
88 | Gamma,
|
---|
89 | Quality,
|
---|
90 | Name,
|
---|
91 | SubType,
|
---|
92 | IncrementalReading,
|
---|
93 | Endianness,
|
---|
94 | Animation,
|
---|
95 | BackgroundColor,
|
---|
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);
|
---|
113 | QScopedPointer<QImageIOHandlerPrivate> d_ptr;
|
---|
114 | private:
|
---|
115 | Q_DISABLE_COPY(QImageIOHandler)
|
---|
116 | };
|
---|
117 |
|
---|
118 | struct Q_GUI_EXPORT QImageIOHandlerFactoryInterface : public QFactoryInterface
|
---|
119 | {
|
---|
120 | virtual QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const = 0;
|
---|
121 | };
|
---|
122 |
|
---|
123 | #define QImageIOHandlerFactoryInterface_iid "com.trolltech.Qt.QImageIOHandlerFactoryInterface"
|
---|
124 | Q_DECLARE_INTERFACE(QImageIOHandlerFactoryInterface, QImageIOHandlerFactoryInterface_iid)
|
---|
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 |
|
---|
148 | QT_END_NAMESPACE
|
---|
149 |
|
---|
150 | QT_END_HEADER
|
---|
151 |
|
---|
152 | #endif // QIMAGEIOHANDLER_H
|
---|