Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
main.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// Copyright (C) 2016 Petroules Corporation.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5#include <qimageiohandler.h>
6#include <qstringlist.h>
7
8#ifndef QT_NO_IMAGEFORMATPLUGIN
9
10#include "qjp2handler_p.h"
11
12#include <qiodevice.h>
13#include <qbytearray.h>
14
16
18{
19 Q_OBJECT
20 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QImageIOHandlerFactoryInterface" FILE "jp2.json")
21
22public:
24 QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const override;
25};
26
27QImageIOPlugin::Capabilities QJp2Plugin::capabilities(QIODevice *device, const QByteArray &format) const
28{
29 if (format == "jp2" || format == "j2k")
30 return Capabilities(CanRead | CanWrite);
31 Capabilities cap;
32 if (!format.isEmpty())
33 return cap;
34 if (!device->isOpen())
35 return cap;
36
37 if (device->isReadable() && QJp2Handler::canRead(device, 0))
38 cap |= CanRead;
39 if (device->isWritable())
40 cap |= CanWrite;
41 return cap;
42}
43
44QImageIOHandler *QJp2Plugin::create(QIODevice *device, const QByteArray &format) const
45{
46 QJp2Handler *handler = new QJp2Handler();
47 handler->setDevice(device);
48 handler->setFormat(format);
49 return handler;
50}
51
52QT_END_NAMESPACE
53
54#include "main.moc"
55
56#endif // !QT_NO_IMAGEFORMATPLUGIN
The QJp2Handler class provides support for reading and writing JPEG 2000 image files with the Qt plug...
QJp2Handler()
Constructs an instance of QJp2Handler.
QImageIOHandler * create(QIODevice *device, const QByteArray &format=QByteArray()) const override
Creates and returns a QImageIOHandler subclass, with device and format set.
Definition main.cpp:44