1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QIMAGEREADER_H
5#define QIMAGEREADER_H
6
7#include <QtGui/qtguiglobal.h>
8#include <QtCore/qbytearray.h>
9#include <QtCore/qcoreapplication.h>
10#include <QtGui/qimage.h>
11#include <QtGui/qimageiohandler.h>
12
13QT_BEGIN_NAMESPACE
14
15
16class QColor;
17class QIODevice;
18class QRect;
19class QSize;
20
21class QImageReaderPrivate;
22class Q_GUI_EXPORT QImageReader
23{
24 Q_DECLARE_TR_FUNCTIONS(QImageReader)
25public:
26 enum ImageReaderError {
27 UnknownError,
28 FileNotFoundError,
29 DeviceError,
30 UnsupportedFormatError,
31 InvalidDataError
32 };
33
34 QImageReader();
35 explicit QImageReader(QIODevice *device, const QByteArray &format = QByteArray());
36 explicit QImageReader(const QString &fileName, const QByteArray &format = QByteArray());
37 ~QImageReader();
38
39 void setFormat(const QByteArray &format);
40 QByteArray format() const;
41
42 void setAutoDetectImageFormat(bool enabled);
43 bool autoDetectImageFormat() const;
44
45 void setDecideFormatFromContent(bool ignored);
46 bool decideFormatFromContent() const;
47
48 void setDevice(QIODevice *device);
49 QIODevice *device() const;
50
51 void setFileName(const QString &fileName);
52 QString fileName() const;
53
54 QSize size() const;
55
56 QImage::Format imageFormat() const;
57
58 QStringList textKeys() const;
59 QString text(const QString &key) const;
60
61 void setClipRect(const QRect &rect);
62 QRect clipRect() const;
63
64 void setScaledSize(const QSize &size);
65 QSize scaledSize() const;
66
67 void setQuality(int quality);
68 int quality() const;
69
70 void setScaledClipRect(const QRect &rect);
71 QRect scaledClipRect() const;
72
73 void setBackgroundColor(const QColor &color);
74 QColor backgroundColor() const;
75
76 bool supportsAnimation() const;
77
78 QImageIOHandler::Transformations transformation() const;
79
80 void setAutoTransform(bool enabled);
81 bool autoTransform() const;
82
83 QByteArray subType() const;
84 QList<QByteArray> supportedSubTypes() const;
85
86 bool canRead() const;
87 QImage read();
88 bool read(QImage *image);
89
90 bool jumpToNextImage();
91 bool jumpToImage(int imageNumber);
92 int loopCount() const;
93 int imageCount() const;
94 int nextImageDelay() const;
95 int currentImageNumber() const;
96 QRect currentImageRect() const;
97
98 ImageReaderError error() const;
99 QString errorString() const;
100
101 bool supportsOption(QImageIOHandler::ImageOption option) const;
102
103 static QByteArray imageFormat(const QString &fileName);
104 static QByteArray imageFormat(QIODevice *device);
105 static QList<QByteArray> supportedImageFormats();
106 static QList<QByteArray> supportedMimeTypes();
107 static QList<QByteArray> imageFormatsForMimeType(const QByteArray &mimeType);
108 static int allocationLimit();
109 static void setAllocationLimit(int mbLimit);
110
111private:
112 Q_DISABLE_COPY(QImageReader)
113 QImageReaderPrivate *d;
114};
115
116QT_END_NAMESPACE
117
118#endif // QIMAGEREADER_H
119

source code of qtbase/src/gui/image/qimagereader.h