1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
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 The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/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 3 as published by the Free Software |
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
21 | ** packaging of this file. Please review the following information to |
22 | ** ensure the GNU Lesser General Public License version 3 requirements |
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
24 | ** |
25 | ** GNU General Public License Usage |
26 | ** Alternatively, this file may be used under the terms of the GNU |
27 | ** General Public License version 2.0 or (at your option) the GNU General |
28 | ** Public license version 3 or any later version approved by the KDE Free |
29 | ** Qt Foundation. The licenses are as published by the Free Software |
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
31 | ** included in the packaging of this file. Please review the following |
32 | ** information to ensure the GNU General Public License requirements will |
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
35 | ** |
36 | ** $QT_END_LICENSE$ |
37 | ** |
38 | ****************************************************************************/ |
39 | |
40 | #ifndef QIMAGEREADER_H |
41 | #define QIMAGEREADER_H |
42 | |
43 | #include <QtGui/qtguiglobal.h> |
44 | #include <QtCore/qbytearray.h> |
45 | #include <QtCore/qcoreapplication.h> |
46 | #include <QtGui/qimage.h> |
47 | #include <QtGui/qimageiohandler.h> |
48 | |
49 | QT_BEGIN_NAMESPACE |
50 | |
51 | |
52 | class QColor; |
53 | class QIODevice; |
54 | class QRect; |
55 | class QSize; |
56 | class QStringList; |
57 | |
58 | class QImageReaderPrivate; |
59 | class Q_GUI_EXPORT QImageReader |
60 | { |
61 | Q_DECLARE_TR_FUNCTIONS(QImageReader) |
62 | public: |
63 | enum ImageReaderError { |
64 | UnknownError, |
65 | FileNotFoundError, |
66 | DeviceError, |
67 | UnsupportedFormatError, |
68 | InvalidDataError |
69 | }; |
70 | |
71 | QImageReader(); |
72 | explicit QImageReader(QIODevice *device, const QByteArray &format = QByteArray()); |
73 | explicit QImageReader(const QString &fileName, const QByteArray &format = QByteArray()); |
74 | ~QImageReader(); |
75 | |
76 | void setFormat(const QByteArray &format); |
77 | QByteArray format() const; |
78 | |
79 | void setAutoDetectImageFormat(bool enabled); |
80 | bool autoDetectImageFormat() const; |
81 | |
82 | void setDecideFormatFromContent(bool ignored); |
83 | bool decideFormatFromContent() const; |
84 | |
85 | void setDevice(QIODevice *device); |
86 | QIODevice *device() const; |
87 | |
88 | void setFileName(const QString &fileName); |
89 | QString fileName() const; |
90 | |
91 | QSize size() const; |
92 | |
93 | QImage::Format imageFormat() const; |
94 | |
95 | QStringList textKeys() const; |
96 | QString text(const QString &key) const; |
97 | |
98 | void setClipRect(const QRect &rect); |
99 | QRect clipRect() const; |
100 | |
101 | void setScaledSize(const QSize &size); |
102 | QSize scaledSize() const; |
103 | |
104 | void setQuality(int quality); |
105 | int quality() const; |
106 | |
107 | void setScaledClipRect(const QRect &rect); |
108 | QRect scaledClipRect() const; |
109 | |
110 | void setBackgroundColor(const QColor &color); |
111 | QColor backgroundColor() const; |
112 | |
113 | bool supportsAnimation() const; |
114 | |
115 | QImageIOHandler::Transformations transformation() const; |
116 | |
117 | void setAutoTransform(bool enabled); |
118 | bool autoTransform() const; |
119 | |
120 | #if QT_DEPRECATED_SINCE(5, 15) |
121 | QT_DEPRECATED_VERSION_X_5_15("Use QColorSpace instead" ) |
122 | void setGamma(float gamma); |
123 | QT_DEPRECATED_VERSION_X_5_15("Use QColorSpace instead" ) |
124 | float gamma() const; |
125 | #endif |
126 | |
127 | QByteArray subType() const; |
128 | QList<QByteArray> supportedSubTypes() const; |
129 | |
130 | bool canRead() const; |
131 | QImage read(); |
132 | bool read(QImage *image); |
133 | |
134 | bool jumpToNextImage(); |
135 | bool jumpToImage(int imageNumber); |
136 | int loopCount() const; |
137 | int imageCount() const; |
138 | int nextImageDelay() const; |
139 | int currentImageNumber() const; |
140 | QRect currentImageRect() const; |
141 | |
142 | ImageReaderError error() const; |
143 | QString errorString() const; |
144 | |
145 | bool supportsOption(QImageIOHandler::ImageOption option) const; |
146 | |
147 | static QByteArray imageFormat(const QString &fileName); |
148 | static QByteArray imageFormat(QIODevice *device); |
149 | static QList<QByteArray> supportedImageFormats(); |
150 | static QList<QByteArray> supportedMimeTypes(); |
151 | static QList<QByteArray> imageFormatsForMimeType(const QByteArray &mimeType); |
152 | |
153 | private: |
154 | Q_DISABLE_COPY(QImageReader) |
155 | QImageReaderPrivate *d; |
156 | }; |
157 | |
158 | QT_END_NAMESPACE |
159 | |
160 | #endif // QIMAGEREADER_H |
161 | |