-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
45 lines (40 loc) · 1.41 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <QImageIOPlugin>
#include <QtPlugin>
#include "qjpeghandler_p.h"
class QJpegTurboPlugin : public QImageIOPlugin
{
public:
QStringList keys() const
{
/* The 'jpeg-turbo' format is supported to allow applications to explicitly use this plugin when
* qjpeg is also loaded. */
return QStringList() << QLatin1String("jpeg") << QLatin1String("jpg")
<< QLatin1String("jpeg-turbo") << QLatin1String("jpeg-ycbcr");
}
Capabilities capabilities(QIODevice *device, const QByteArray &format) const
{
if (format == "jpeg" || format == "jpg" || format == "jpeg-turbo")
return Capabilities(CanRead | CanWrite);
else if (format == "jpeg-ycbcr")
return Capabilities(CanRead);
else if (!format.isEmpty())
return 0;
else if (!device->isOpen())
return 0;
Capabilities cap;
if (device->isReadable() && QJpegHandler::canRead(device))
cap |= CanRead;
if (device->isWritable())
cap |= CanWrite;
return cap;
}
QImageIOHandler *create(QIODevice *device, const QByteArray &format) const
{
QImageIOHandler *handler = new QJpegHandler;
handler->setDevice(device);
handler->setFormat(format);
return handler;
}
};
Q_EXPORT_STATIC_PLUGIN(QJpegTurboPlugin)
Q_EXPORT_PLUGIN2(qjpeg-turbo, QJpegTurboPlugin)