blob: 36e074f5d2001066ff700e45a1aaec988ae77f94 (
plain)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qmacheifhandler.h"
#include <QVariant>
QT_BEGIN_NAMESPACE
QMacHeifHandler::QMacHeifHandler()
: d(new QIIOFHelper(this))
{
}
QMacHeifHandler::~QMacHeifHandler()
{
}
bool QMacHeifHandler::canRead(QIODevice *iod)
{
bool bCanRead = false;
char buf[12];
if (iod && iod->peek(buf, 12) == 12) {
bCanRead = (!qstrncmp(buf + 4, "ftyp", 4) &&
(!qstrncmp(buf + 8, "heic", 4) ||
!qstrncmp(buf + 8, "heix", 4) ||
!qstrncmp(buf + 8, "mif1", 4)));
}
return bCanRead;
}
bool QMacHeifHandler::canRead() const
{
if (canRead(device())) {
setFormat("heic");
return true;
}
return false;
}
bool QMacHeifHandler::read(QImage *image)
{
return d->readImage(image);
}
bool QMacHeifHandler::write(const QImage &image)
{
return d->writeImage(image, QStringLiteral("public.heic"));
}
QVariant QMacHeifHandler::option(ImageOption option) const
{
return d->imageProperty(option);
}
void QMacHeifHandler::setOption(ImageOption option, const QVariant &value)
{
d->setOption(option, value);
}
bool QMacHeifHandler::supportsOption(ImageOption option) const
{
return option == Quality
|| option == Size
|| option == ImageTransformation;
}
QT_END_NAMESPACE
|