/src/qtbase/src/plugins/imageformats/jpeg/main.cpp
Line | Count | Source |
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 | | |
13 | | QT_BEGIN_NAMESPACE |
14 | | |
15 | | class QJpegPlugin : public QImageIOPlugin |
16 | | { |
17 | 0 | Q_OBJECT |
18 | 0 | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QImageIOHandlerFactoryInterface" FILE "jpeg.json") |
19 | 0 | public: |
20 | 0 | Capabilities capabilities(QIODevice *device, const QByteArray &format) const override; |
21 | 0 | QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const override; |
22 | 0 | }; |
23 | 0 |
|
24 | 0 | QImageIOPlugin::Capabilities QJpegPlugin::capabilities(QIODevice *device, const QByteArray &format) const |
25 | 131k | { |
26 | 131k | if (format == "jpeg" || format == "jpg" || format == "jfif") |
27 | 38.7k | return Capabilities(CanRead | CanWrite); |
28 | 92.6k | if (!format.isEmpty()) |
29 | 6.31k | return { }; |
30 | 86.2k | if (!device->isOpen()) |
31 | 0 | return { }; |
32 | | |
33 | 86.2k | Capabilities cap; |
34 | 86.2k | if (device->isReadable() && QJpegHandler::canRead(device)) |
35 | 10.9k | cap |= CanRead; |
36 | 86.2k | if (device->isWritable()) |
37 | 0 | cap |= CanWrite; |
38 | 86.2k | return cap; |
39 | 86.2k | } |
40 | | |
41 | | QImageIOHandler *QJpegPlugin::create(QIODevice *device, const QByteArray &format) const |
42 | 49.6k | { |
43 | 49.6k | QImageIOHandler *handler = new QJpegHandler; |
44 | 49.6k | handler->setDevice(device); |
45 | 49.6k | handler->setFormat(format); |
46 | 49.6k | return handler; |
47 | 49.6k | } |
48 | | |
49 | | QT_END_NAMESPACE |
50 | | |
51 | | #include "main.moc" |