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
qmacjp2handler.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:critical reason:data-parser
4
7#include <QVariant>
8
10
11using namespace NS_IIOF_HELPERS;
12
25
26
31
35
36bool QMacJp2Handler::canRead(QIODevice *iod)
37{
38 bool bCanRead = false;
39 char buf[12];
40 if (iod && iod->peek(buf, 12) == 12)
41 bCanRead = !memcmp(buf, "\000\000\000\fjP \r\n\207\n", 12);
42 return bCanRead;
43}
44
46{
47 if (canRead(device())) {
48 setFormat("jp2");
49 return true;
50 }
51 return false;
52}
53
54bool QMacJp2Handler::read(QImage *image)
55{
56 return QIIOFHelpers::readImage(this, image);
57}
58
59bool QMacJp2Handler::write(const QImage &image)
60{
61 return QIIOFHelpers::writeImage(this, image, QStringLiteral("public.jpeg-2000"));
62}
63
64QVariant QMacJp2Handler::option(ImageOption option) const
65{
66 Q_D(const QMacJp2Handler);
67 if (option == Quality)
68 return QVariant(d->writeQuality);
69 return QVariant();
70}
71
72void QMacJp2Handler::setOption(ImageOption option, const QVariant &value)
73{
74 Q_D(QMacJp2Handler);
75 if (option == Quality) {
76 bool ok;
77 const int quality = value.toInt(&ok);
78 if (ok)
79 d->writeQuality = quality;
80 }
81}
82
83bool QMacJp2Handler::supportsOption(ImageOption option) const
84{
85 return (option == Quality);
86}
87
88QT_END_NAMESPACE
QMacJp2Handler * q_ptr
static bool canRead(QIODevice *iod)
bool write(const QImage &image) override
Writes the image image to the assigned device.
bool supportsOption(ImageOption option) const override
Returns true if the QImageIOHandler supports the option option; otherwise returns false.
void setOption(ImageOption option, const QVariant &value) override
Sets the option option with the value value.
bool read(QImage *image) override
Read an image from the device, and stores it in image.
bool canRead() const override
Returns true if an image can be read from the device (i.e., the image format is supported,...
QVariant option(ImageOption option) const override
Returns the value assigned to option as a QVariant.