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
49QT_BEGIN_NAMESPACE
50
51
52class QColor;
53class QIODevice;
54class QRect;
55class QSize;
56
57class QImageReaderPrivate;
58class Q_GUI_EXPORT QImageReader
59{
60 Q_DECLARE_TR_FUNCTIONS(QImageReader)
61public:
62 enum ImageReaderError {
63 UnknownError,
64 FileNotFoundError,
65 DeviceError,
66 UnsupportedFormatError,
67 InvalidDataError
68 };
69
70 QImageReader();
71 explicit QImageReader(QIODevice *device, const QByteArray &format = QByteArray());
72 explicit QImageReader(const QString &fileName, const QByteArray &format = QByteArray());
73 ~QImageReader();
74
75 void setFormat(const QByteArray &format);
76 QByteArray format() const;
77
78 void setAutoDetectImageFormat(bool enabled);
79 bool autoDetectImageFormat() const;
80
81 void setDecideFormatFromContent(bool ignored);
82 bool decideFormatFromContent() const;
83
84 void setDevice(QIODevice *device);
85 QIODevice *device() const;
86
87 void setFileName(const QString &fileName);
88 QString fileName() const;
89
90 QSize size() const;
91
92 QImage::Format imageFormat() const;
93
94 QStringList textKeys() const;
95 QString text(const QString &key) const;
96
97 void setClipRect(const QRect &rect);
98 QRect clipRect() const;
99
100 void setScaledSize(const QSize &size);
101 QSize scaledSize() const;
102
103 void setQuality(int quality);
104 int quality() const;
105
106 void setScaledClipRect(const QRect &rect);
107 QRect scaledClipRect() const;
108
109 void setBackgroundColor(const QColor &color);
110 QColor backgroundColor() const;
111
112 bool supportsAnimation() const;
113
114 QImageIOHandler::Transformations transformation() const;
115
116 void setAutoTransform(bool enabled);
117 bool autoTransform() const;
118
119 QByteArray subType() const;
120 QList<QByteArray> supportedSubTypes() const;
121
122 bool canRead() const;
123 QImage read();
124 bool read(QImage *image);
125
126 bool jumpToNextImage();
127 bool jumpToImage(int imageNumber);
128 int loopCount() const;
129 int imageCount() const;
130 int nextImageDelay() const;
131 int currentImageNumber() const;
132 QRect currentImageRect() const;
133
134 ImageReaderError error() const;
135 QString errorString() const;
136
137 bool supportsOption(QImageIOHandler::ImageOption option) const;
138
139 static QByteArray imageFormat(const QString &fileName);
140 static QByteArray imageFormat(QIODevice *device);
141 static QList<QByteArray> supportedImageFormats();
142 static QList<QByteArray> supportedMimeTypes();
143 static QList<QByteArray> imageFormatsForMimeType(const QByteArray &mimeType);
144 static int allocationLimit();
145 static void setAllocationLimit(int mbLimit);
146
147private:
148 Q_DISABLE_COPY(QImageReader)
149 QImageReaderPrivate *d;
150};
151
152QT_END_NAMESPACE
153
154#endif // QIMAGEREADER_H
155