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#ifdef QT_NO_IMAGEFORMAT_JPEG
9#undef QT_NO_IMAGEFORMAT_JPEG
10#endif
11#include <qjpeghandler_p.h>
12
14
16{
17 Q_OBJECT
18 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QImageIOHandlerFactoryInterface" FILE "jpeg.json")
19public:
21 QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const override;
22};
23
24QImageIOPlugin::Capabilities QJpegPlugin::capabilities(QIODevice *device, const QByteArray &format) const
25{
26 if (format == "jpeg" || format == "jpg" || format == "jfif")
27 return Capabilities(CanRead | CanWrite);
28 if (!format.isEmpty())
29 return { };
30 if (!device->isOpen())
31 return { };
32
33 Capabilities cap;
34 if (device->isReadable() && QJpegHandler::canRead(device))
35 cap |= CanRead;
36 if (device->isWritable())
37 cap |= CanWrite;
38 return cap;
39}
40
41QImageIOHandler *QJpegPlugin::create(QIODevice *device, const QByteArray &format) const
42{
43 QImageIOHandler *handler = new QJpegHandler;
44 handler->setDevice(device);
45 handler->setFormat(format);
46 return handler;
47}
48
49QT_END_NAMESPACE
50
51#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:41
Combined button and popup list for selecting options.