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// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#include <qimageiohandler.h>
6#include <qstringlist.h>
7
8#include <qjpeghandler_p.h>
9
11
13{
14 Q_OBJECT
15 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QImageIOHandlerFactoryInterface" FILE "jpeg.json")
16public:
18 QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const override;
19};
20
21QImageIOPlugin::Capabilities QJpegPlugin::capabilities(QIODevice *device, const QByteArray &format) const
22{
23 if (format == "jpeg" || format == "jpg" || format == "jfif")
24 return Capabilities(CanRead | CanWrite);
25 if (!format.isEmpty())
26 return { };
27 if (!device->isOpen())
28 return { };
29
30 Capabilities cap;
31 if (device->isReadable() && QJpegHandler::canRead(device))
32 cap |= CanRead;
33 if (device->isWritable())
34 cap |= CanWrite;
35 return cap;
36}
37
38QImageIOHandler *QJpegPlugin::create(QIODevice *device, const QByteArray &format) const
39{
40 QImageIOHandler *handler = new QJpegHandler;
41 handler->setDevice(device);
42 handler->setFormat(format);
43 return handler;
44}
45
46QT_END_NAMESPACE
47
48#include "main.moc"
QImageIOHandler * create(QIODevice *device, const QByteArray &format=QByteArray()) const override
Creates and returns a QImageIOHandler subclass, with device and format set.
Definition main.cpp:38
Combined button and popup list for selecting options.