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 QIMAGEWRITER_H
5#define QIMAGEWRITER_H
6
7#include <QtGui/qtguiglobal.h>
8#include <QtCore/qbytearray.h>
9#include <QtCore/qcoreapplication.h>
10#include <QtCore/qlist.h>
11#include <QtGui/qimageiohandler.h>
12
13QT_BEGIN_NAMESPACE
14
15
16class QIODevice;
17class QImage;
18
19class QImageWriterPrivate;
20class Q_GUI_EXPORT QImageWriter
21{
22 Q_DECLARE_TR_FUNCTIONS(QImageWriter)
23public:
24 enum ImageWriterError {
25 UnknownError,
26 DeviceError,
27 UnsupportedFormatError,
28 InvalidImageError
29 };
30
31 QImageWriter();
32 explicit QImageWriter(QIODevice *device, const QByteArray &format);
33 explicit QImageWriter(const QString &fileName, const QByteArray &format = QByteArray());
34 ~QImageWriter();
35
36 void setFormat(const QByteArray &format);
37 QByteArray format() const;
38
39 void setDevice(QIODevice *device);
40 QIODevice *device() const;
41
42 void setFileName(const QString &fileName);
43 QString fileName() const;
44
45 void setQuality(int quality);
46 int quality() const;
47
48 void setCompression(int compression);
49 int compression() const;
50
51 void setSubType(const QByteArray &type);
52 QByteArray subType() const;
53 QList<QByteArray> supportedSubTypes() const;
54
55 void setOptimizedWrite(bool optimize);
56 bool optimizedWrite() const;
57
58 void setProgressiveScanWrite(bool progressive);
59 bool progressiveScanWrite() const;
60
61 QImageIOHandler::Transformations transformation() const;
62 void setTransformation(QImageIOHandler::Transformations orientation);
63
64 void setText(const QString &key, const QString &text);
65
66 bool canWrite() const;
67 bool write(const QImage &image);
68
69 ImageWriterError error() const;
70 QString errorString() const;
71
72 bool supportsOption(QImageIOHandler::ImageOption option) const;
73
74 static QList<QByteArray> supportedImageFormats();
75 static QList<QByteArray> supportedMimeTypes();
76 static QList<QByteArray> imageFormatsForMimeType(const QByteArray &mimeType);
77
78private:
79 Q_DISABLE_COPY(QImageWriter)
80 QImageWriterPrivate *d;
81};
82
83QT_END_NAMESPACE
84
85#endif // QIMAGEWRITER_H
86

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