Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
4#include "qmacjp2handler.h"
5#include "qiiofhelpers_p.h"
6#include <QVariant>
7
9
10using namespace NS_IIOF_HELPERS;
11
24
25
30
34
36{
37 bool bCanRead = false;
38 char buf[12];
39 if (iod && iod->peek(buf, 12) == 12)
40 bCanRead = !qstrncmp(buf, "\000\000\000\fjP \r\n\207\n", 12);
41 return bCanRead;
42}
43
45{
46 if (canRead(device())) {
47 setFormat("jp2");
48 return true;
49 }
50 return false;
51}
52
57
59{
60 return QIIOFHelpers::writeImage(this, image, QStringLiteral("public.jpeg-2000"));
61}
62
64{
65 Q_D(const QMacJp2Handler);
66 if (option == Quality)
67 return QVariant(d->writeQuality);
68 return QVariant();
69}
70
72{
73 Q_D(QMacJp2Handler);
74 if (option == Quality) {
75 bool ok;
76 const int quality = value.toInt(&ok);
77 if (ok)
78 d->writeQuality = quality;
79 }
80}
81
86
static bool writeImage(QImageIOHandler *q_ptr, const QImage &in, const QString &uti)
static bool readImage(QImageIOHandler *q_ptr, QImage *out)
\inmodule QtCore \reentrant
Definition qiodevice.h:34
qint64 peek(char *data, qint64 maxlen)
ImageOption
This enum describes the different options supported by QImageIOHandler.
QIODevice * device() const
Returns the device currently assigned to the QImageIOHandler.
void setFormat(const QByteArray &format)
Sets the format of the QImageIOHandler to format.
\inmodule QtGui
Definition qimage.h:37
QMacJp2Handler * q_ptr
QMacJp2HandlerPrivate(QMacJp2Handler *q_ptr)
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.
\inmodule QtCore
Definition qvariant.h:65
#define this
Definition dialogs.cpp:9
Combined button and popup list for selecting options.
Definition image.cpp:4
int qstrncmp(const char *str1, const char *str2, size_t len)
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLenum GLuint GLenum GLsizei const GLchar * buf
GLuint GLenum option
#define QStringLiteral(str)