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
qmacheifhandler.cpp
Go to the documentation of this file.
1// Copyright (C) 2017 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
6#include <QVariant>
7
9
10QMacHeifHandler::QMacHeifHandler()
11 : d(new QIIOFHelper(this))
12{
13}
14
18
19bool QMacHeifHandler::canRead(QIODevice *iod)
20{
21 bool bCanRead = false;
22 char buf[12];
23 if (iod && iod->peek(buf, 12) == 12) {
24 bCanRead = (!qstrncmp(buf + 4, "ftyp", 4) &&
25 (!qstrncmp(buf + 8, "heic", 4) ||
26 !qstrncmp(buf + 8, "heix", 4) ||
27 !qstrncmp(buf + 8, "msf1", 4) ||
28 !qstrncmp(buf + 8, "mif1", 4)));
29 }
30 return bCanRead;
31}
32
34{
35 if (canRead(device())) {
36 setFormat("heic");
37 return true;
38 }
39 return false;
40}
41
42bool QMacHeifHandler::read(QImage *image)
43{
44 return d->readImage(image);
45}
46
47bool QMacHeifHandler::write(const QImage &image)
48{
49 return d->writeImage(image, QStringLiteral("public.heic"));
50}
51
52QVariant QMacHeifHandler::option(ImageOption option) const
53{
54 return d->imageProperty(option);
55}
56
57void QMacHeifHandler::setOption(ImageOption option, const QVariant &value)
58{
59 d->setOption(option, value);
60}
61
62bool QMacHeifHandler::supportsOption(ImageOption option) const
63{
64 return option == Quality
65 || option == Size
66 || option == ImageTransformation;
67}
68
69QT_END_NAMESPACE
bool read(QImage *image) override
Read an image from the device, and stores it in image.
static bool canRead(QIODevice *iod)
QVariant option(ImageOption option) const override
Returns the value assigned to option as a QVariant.
bool canRead() const override
Returns true if an image can be read from the device (i.e., the image format is supported,...
~QMacHeifHandler() override
bool supportsOption(ImageOption option) const override
Returns true if the QImageIOHandler supports the option option; otherwise returns false.
bool write(const QImage &image) override
Writes the image image to the assigned device.
void setOption(ImageOption option, const QVariant &value) override
Sets the option option with the value value.