| 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 | #include <qstringlist.h> |
| 6 | |
| 7 | #ifdef QT_NO_IMAGEFORMAT_GIF |
| 8 | #undef QT_NO_IMAGEFORMAT_GIF |
| 9 | #endif |
| 10 | #include <qgifhandler_p.h> |
| 11 | |
| 12 | QT_BEGIN_NAMESPACE |
| 13 | |
| 14 | class QGifPlugin : public QImageIOPlugin |
| 15 | { |
| 16 | Q_OBJECT |
| 17 | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QImageIOHandlerFactoryInterface"FILE "gif.json") |
| 18 | public: |
| 19 | QGifPlugin(); |
| 20 | ~QGifPlugin(); |
| 21 | |
| 22 | Capabilities capabilities(QIODevice *device, const QByteArray &format) const override; |
| 23 | QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const override; |
| 24 | }; |
| 25 | |
| 26 | QGifPlugin::QGifPlugin() |
| 27 | { |
| 28 | } |
| 29 | |
| 30 | QGifPlugin::~QGifPlugin() |
| 31 | { |
| 32 | } |
| 33 | |
| 34 | QImageIOPlugin::Capabilities QGifPlugin::capabilities(QIODevice *device, const QByteArray &format) const |
| 35 | { |
| 36 | if (format == "gif"|| (device && device->isReadable() && QGifHandler::canRead(device))) |
| 37 | return Capabilities(CanRead); |
| 38 | return { }; |
| 39 | } |
| 40 | |
| 41 | QImageIOHandler *QGifPlugin::create(QIODevice *device, const QByteArray &format) const |
| 42 | { |
| 43 | QImageIOHandler *handler = new QGifHandler; |
| 44 | handler->setDevice(device); |
| 45 | handler->setFormat(format); |
| 46 | return handler; |
| 47 | } |
| 48 | |
| 49 | QT_END_NAMESPACE |
| 50 | |
| 51 | #include "main.moc" |
| 52 |
