| 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 | #include <qimageiohandler.h> | 
| 5 | |
| 6 | #ifndef QT_NO_IMAGEFORMATPLUGIN | 
| 7 | |
| 8 | #ifdef QT_NO_IMAGEFORMAT_WBMP | 
| 9 | #undef QT_NO_IMAGEFORMAT_WBMP | 
| 10 | #endif | 
| 11 | |
| 12 | #include "qwbmphandler_p.h" | 
| 13 | |
| 14 | QT_BEGIN_NAMESPACE | 
| 15 | |
| 16 | class QWbmpPlugin : public QImageIOPlugin | 
| 17 | { | 
| 18 | Q_OBJECT | 
| 19 |     Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QImageIOHandlerFactoryInterface"FILE "wbmp.json")  | 
| 20 | |
| 21 | public: | 
| 22 | QImageIOPlugin::Capabilities capabilities(QIODevice *device, const QByteArray &format) const override; | 
| 23 | QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const override; | 
| 24 | }; | 
| 25 | |
| 26 | QImageIOPlugin::Capabilities QWbmpPlugin::capabilities(QIODevice *device, const QByteArray &format) const | 
| 27 | { | 
| 28 |     if (format == "wbmp")  | 
| 29 | return Capabilities(CanRead | CanWrite); | 
| 30 | |
| 31 | Capabilities cap; | 
| 32 | if (!format.isEmpty()) | 
| 33 | return cap; | 
| 34 | |
| 35 | if (!device->isOpen()) | 
| 36 | return cap; | 
| 37 | |
| 38 | if (device->isReadable() && QWbmpHandler::canRead(device)) | 
| 39 | cap |= CanRead; | 
| 40 | |
| 41 | if (device->isWritable()) | 
| 42 | cap |= CanWrite; | 
| 43 | |
| 44 | return cap; | 
| 45 | } | 
| 46 | |
| 47 | QImageIOHandler * QWbmpPlugin::create(QIODevice *device, const QByteArray &format) const | 
| 48 | { | 
| 49 | QImageIOHandler *handler = new QWbmpHandler(device); | 
| 50 | |
| 51 | handler->setFormat(format); | 
| 52 | return handler; | 
| 53 | } | 
| 54 | |
| 55 | QT_END_NAMESPACE | 
| 56 | |
| 57 | #include "main.moc" | 
| 58 | |
| 59 | #endif /* QT_NO_IMAGEFORMATPLUGIN */ | 
| 60 | 
