Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
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
5
#
include
"qmacjp2handler.h"
6
#
include
"qiiofhelpers_p.h"
7
#
include
<
QVariant
>
8
9
QT_BEGIN_NAMESPACE
10
11
using
namespace
NS_IIOF_HELPERS;
12
13
class
QMacJp2HandlerPrivate
14
{
15
Q_DECLARE_PUBLIC(QMacJp2Handler)
16
Q_DISABLE_COPY
(
QMacJp2HandlerPrivate
)
17
public
:
18
QMacJp2HandlerPrivate
(
QMacJp2Handler
*
q_ptr
)
19
:
writeQuality
(-1),
q_ptr
(
q_ptr
)
20
{}
21
22
int
writeQuality
;
23
QMacJp2Handler
*
q_ptr
;
24
};
25
26
27
QMacJp2Handler
::
QMacJp2Handler
()
28
:
d_ptr
(
new
QMacJp2HandlerPrivate
(
this
))
29
{
30
}
31
32
QMacJp2Handler
::~
QMacJp2Handler
()
33
{
34
}
35
36
bool
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
45
bool
QMacJp2Handler
::
canRead
()
const
46
{
47
if
(canRead(device())) {
48
setFormat(
"jp2"
);
49
return
true
;
50
}
51
return
false
;
52
}
53
54
bool
QMacJp2Handler
::
read
(QImage *image)
55
{
56
return
QIIOFHelpers::readImage(
this
, image);
57
}
58
59
bool
QMacJp2Handler
::
write
(
const
QImage &image)
60
{
61
return
QIIOFHelpers::writeImage(
this
, image, QStringLiteral(
"public.jpeg-2000"
));
62
}
63
64
QVariant
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
72
void
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
83
bool
QMacJp2Handler
::
supportsOption
(ImageOption option)
const
84
{
85
return
(option == Quality);
86
}
87
88
QT_END_NAMESPACE
QMacJp2HandlerPrivate
Definition
qmacjp2handler.cpp:14
QMacJp2HandlerPrivate::q_ptr
QMacJp2Handler * q_ptr
Definition
qmacjp2handler.cpp:23
QMacJp2Handler
Definition
qmacjp2handler.h:21
QMacJp2Handler::QMacJp2Handler
QMacJp2Handler()
Definition
qmacjp2handler.cpp:27
QMacJp2Handler::canRead
static bool canRead(QIODevice *iod)
Definition
qmacjp2handler.cpp:36
QMacJp2Handler::write
bool write(const QImage &image) override
Writes the image image to the assigned device.
Definition
qmacjp2handler.cpp:59
QMacJp2Handler::supportsOption
bool supportsOption(ImageOption option) const override
Returns true if the QImageIOHandler supports the option option; otherwise returns false.
Definition
qmacjp2handler.cpp:83
QMacJp2Handler::setOption
void setOption(ImageOption option, const QVariant &value) override
Sets the option option with the value value.
Definition
qmacjp2handler.cpp:72
QMacJp2Handler::~QMacJp2Handler
~QMacJp2Handler()
Definition
qmacjp2handler.cpp:32
QMacJp2Handler::read
bool read(QImage *image) override
Read an image from the device, and stores it in image.
Definition
qmacjp2handler.cpp:54
QMacJp2Handler::canRead
bool canRead() const override
Returns true if an image can be read from the device (i.e., the image format is supported,...
Definition
qmacjp2handler.cpp:45
QMacJp2Handler::option
QVariant option(ImageOption option) const override
Returns the value assigned to option as a QVariant.
Definition
qmacjp2handler.cpp:64
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtimageformats
src
plugins
imageformats
macjp2
qmacjp2handler.cpp
Generated on
for Qt by
1.18.0