1 /**************************************************************************** 2 ** 3 ** DQt - D bindings for the Qt Toolkit 4 ** 5 ** GNU Lesser General Public License Usage 6 ** This file may be used under the terms of the GNU Lesser 7 ** General Public License version 3 as published by the Free Software 8 ** Foundation and appearing in the file LICENSE.LGPL3 included in the 9 ** packaging of this file. Please review the following information to 10 ** ensure the GNU Lesser General Public License version 3 requirements 11 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. 12 ** 13 ****************************************************************************/ 14 module qt.gui.imageiohandler; 15 extern(C++): 16 17 import qt.config; 18 import qt.core.bytearray; 19 import qt.core.flags; 20 import qt.core.iodevice; 21 import qt.core.rect; 22 import qt.core.scopedpointer; 23 import qt.core.variant; 24 import qt.gui.image; 25 import qt.helpers; 26 static if(!defined!"QT_NO_IMAGEFORMATPLUGIN") 27 import qt.core.object; 28 29 /+ class QImage; 30 class QRect; 31 class QSize; 32 class QVariant; +/ 33 34 extern(C++, class) struct QImageIOHandlerPrivate; 35 class /+ Q_GUI_EXPORT +/ QImageIOHandler 36 { 37 private: 38 /+ Q_DECLARE_PRIVATE(QImageIOHandler) +/ 39 public: 40 this(); 41 /+ virtual +/~this(); 42 43 final void setDevice(QIODevice device); 44 final QIODevice device() const; 45 46 final void setFormat(ref const(QByteArray) format); 47 final void setFormat(ref const(QByteArray) format) const; 48 final QByteArray format() const; 49 50 /+ QT_DEPRECATED_X("Use QImageIOHandler::format() instead") +/ 51 /+ virtual +/ QByteArray name() const; 52 53 /+ virtual +/ abstract bool canRead() const; 54 /+ virtual +/ abstract bool read(QImage* image); 55 /+ virtual +/ bool write(ref const(QImage) image); 56 57 enum ImageOption { 58 Size, 59 ClipRect, 60 Description, 61 ScaledClipRect, 62 ScaledSize, 63 CompressionRatio, 64 Gamma, 65 Quality, 66 Name, 67 SubType, 68 IncrementalReading, 69 Endianness, 70 Animation, 71 BackgroundColor, 72 ImageFormat, 73 SupportedSubTypes, 74 OptimizedWrite, 75 ProgressiveScanWrite, 76 ImageTransformation 77 /+ #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +/ 78 , TransformedByDefault 79 /+ #endif +/ 80 } 81 82 enum Transformation { 83 TransformationNone = 0, 84 TransformationMirror = 1, 85 TransformationFlip = 2, 86 TransformationRotate180 = Transformation.TransformationMirror | Transformation.TransformationFlip, 87 TransformationRotate90 = 4, 88 TransformationMirrorAndRotate90 = Transformation.TransformationMirror | Transformation.TransformationRotate90, 89 TransformationFlipAndRotate90 = Transformation.TransformationFlip | Transformation.TransformationRotate90, 90 TransformationRotate270 = Transformation.TransformationRotate180 | Transformation.TransformationRotate90 91 } 92 /+ Q_DECLARE_FLAGS(Transformations, Transformation) +/ 93 alias Transformations = QFlags!(Transformation); 94 /+ virtual +/ QVariant option(ImageOption option) const; 95 /+ virtual +/ void setOption(ImageOption option, ref const(QVariant) value); 96 /+ virtual +/ bool supportsOption(ImageOption option) const; 97 98 // incremental loading 99 /+ virtual +/ bool jumpToNextImage(); 100 /+ virtual +/ bool jumpToImage(int imageNumber); 101 /+ virtual +/ int loopCount() const; 102 /+ virtual +/ int imageCount() const; 103 /+ virtual +/ int nextImageDelay() const; 104 /+ virtual +/ int currentImageNumber() const; 105 /+ virtual +/ QRect currentImageRect() const; 106 107 protected: 108 this(ref QImageIOHandlerPrivate dd); 109 QScopedPointer!(QImageIOHandlerPrivate) d_ptr; 110 private: 111 /+ Q_DISABLE_COPY(QImageIOHandler) +/ 112 } 113 114 static if(!defined!"QT_NO_IMAGEFORMATPLUGIN") 115 { 116 117 /+ #define QImageIOHandlerFactoryInterface_iid "org.qt-project.Qt.QImageIOHandlerFactoryInterface" +/ 118 119 class /+ Q_GUI_EXPORT +/ QImageIOPlugin : QObject 120 { 121 mixin(Q_OBJECT); 122 public: 123 /+ explicit +/this(QObject parent = null); 124 ~this(); 125 126 enum Capability { 127 CanRead = 0x1, 128 CanWrite = 0x2, 129 CanReadIncremental = 0x4 130 } 131 /+ Q_DECLARE_FLAGS(Capabilities, Capability) +/ 132 alias Capabilities = QFlags!(Capability); 133 /+ virtual +/ abstract Capabilities capabilities(QIODevice device, ref const(QByteArray) format) const; 134 /+ virtual +/ abstract QImageIOHandler create(QIODevice device, ref const(QByteArray) format = globalInitVar!QByteArray) const; 135 } 136 /+pragma(inline, true) QFlags!(QImageIOPlugin.Capabilities.enum_type) operator |(QImageIOPlugin.Capabilities.enum_type f1, QImageIOPlugin.Capabilities.enum_type f2)/+noexcept+/{return QFlags!(QImageIOPlugin.Capabilities.enum_type)(f1)|f2;}+/ 137 /+pragma(inline, true) QFlags!(QImageIOPlugin.Capabilities.enum_type) operator |(QImageIOPlugin.Capabilities.enum_type f1, QFlags!(QImageIOPlugin.Capabilities.enum_type) f2)/+noexcept+/{return f2|f1;}+/ 138 /+pragma(inline, true) QIncompatibleFlag operator |(QImageIOPlugin.Capabilities.enum_type f1, int f2)/+noexcept+/{return QIncompatibleFlag(int(f1)|f2);}+/ 139 140 /+ Q_DECLARE_OPERATORS_FOR_FLAGS(QImageIOPlugin::Capabilities) +/ 141 } 142