1 /*
2  * DQt - D bindings for the Qt Toolkit
3  *
4  * GNU Lesser General Public License Usage
5  * This file may be used under the terms of the GNU Lesser
6  * General Public License version 3 as published by the Free Software
7  * Foundation and appearing in the file LICENSE.LGPL3 included in the
8  * packaging of this file. Please review the following information to
9  * ensure the GNU Lesser General Public License version 3 requirements
10  * will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
11  */
12 module qt.gui.imagewriter;
13 extern(C++):
14 
15 import qt.config;
16 import qt.core.bytearray;
17 import qt.core.coreapplication;
18 import qt.core.iodevice;
19 import qt.core.list;
20 import qt.core.string;
21 import qt.gui.image;
22 import qt.gui.imageiohandler;
23 import qt.helpers;
24 
25 
26 extern(C++, class) struct QImageWriterPrivate;
27 /// Binding for C++ class [QImageWriter](https://doc.qt.io/qt-6/qimagewriter.html).
28 extern(C++, class) struct /+ Q_GUI_EXPORT +/ QImageWriter
29 {
30     mixin(Q_DECLARE_TR_FUNCTIONS(q{QImageWriter}));
31 public:
32     enum ImageWriterError {
33         UnknownError,
34         DeviceError,
35         UnsupportedFormatError,
36         InvalidImageError
37     }
38 
39     @disable this();
40     pragma(mangle, defaultConstructorMangling(__traits(identifier, typeof(this))))
41     ref typeof(this) rawConstructor();
42     static typeof(this) create()
43     {
44         typeof(this) r = typeof(this).init;
45         r.rawConstructor();
46         return r;
47     }
48 
49     /+ explicit +/this(QIODevice device, ref const(QByteArray) format);
50     /+ explicit +/this(ref const(QString) fileName, ref const(QByteArray) format = globalInitVar!QByteArray);
51     ~this();
52 
53     void setFormat(ref const(QByteArray) format);
54     QByteArray format() const;
55 
56     void setDevice(QIODevice device);
57     QIODevice device() const;
58 
59     void setFileName(ref const(QString) fileName);
60     QString fileName() const;
61 
62     void setQuality(int quality);
63     int quality() const;
64 
65     void setCompression(int compression);
66     int compression() const;
67 
68     void setSubType(ref const(QByteArray) type);
69     QByteArray subType() const;
70     QList!(QByteArray) supportedSubTypes() const;
71 
72     void setOptimizedWrite(bool optimize);
73     bool optimizedWrite() const;
74 
75     void setProgressiveScanWrite(bool progressive);
76     bool progressiveScanWrite() const;
77 
78     QImageIOHandler.Transformations transformation() const;
79     void setTransformation(QImageIOHandler.Transformations orientation);
80 
81     void setText(ref const(QString) key, ref const(QString) text);
82 
83     bool canWrite() const;
84     bool write(ref const(QImage) image);
85 
86     ImageWriterError error() const;
87     QString errorString() const;
88 
89     bool supportsOption(QImageIOHandler.ImageOption option) const;
90 
91     static QList!(QByteArray) supportedImageFormats();
92     static QList!(QByteArray) supportedMimeTypes();
93     static QList!(QByteArray) imageFormatsForMimeType(ref const(QByteArray) mimeType);
94 
95 private:
96     /+ Q_DISABLE_COPY(QImageWriter) +/
97 @disable this(this);
98 /+this(ref const(QImageWriter));+//+ref QImageWriter operator =(ref const(QImageWriter));+/    QImageWriterPrivate* d;
99     mixin(CREATE_CONVENIENCE_WRAPPERS);
100 }
101