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
qicnshandler_p.h
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// Copyright (C) 2016 Alex Char.
3
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
// Qt-Security score:critical reason:data-parser
5
6
#
ifndef
QICNSHANDLER_P_H
7
#
define
QICNSHANDLER_P_H
8
9
#
include
<
QtGui
/
qimageiohandler
.
h
>
10
#
include
<
QtCore
/
qlist
.
h
>
11
12
#
ifndef
QT_NO_DATASTREAM
13
14
#
define
MAKEOSTYPE
(
c0
,
c1
,
c2
,
c3
)
(
(
(
quint8
)
c0
<<
24
)
|
(
(
quint8
)
c1
<<
16
)
|
(
(
quint8
)
c2
<<
8
)
|
(
quint8
)
c3
)
15
16
QT_BEGIN_NAMESPACE
17
18
struct
ICNSBlockHeader
19
{
20
enum
OS {
21
TypeIcns =
MAKEOSTYPE
(
'i'
,
'c'
,
'n'
,
's'
),
// Icns container magic
22
TypeToc =
MAKEOSTYPE
(
'T'
,
'O'
,
'C'
,
' '
),
// Table of contents
23
TypeIcnv =
MAKEOSTYPE
(
'i'
,
'c'
,
'n'
,
'V'
),
// Icon Composer version
24
// Legacy:
25
TypeClut =
MAKEOSTYPE
(
'c'
,
'l'
,
'u'
,
't'
),
// Color look-up table (pre-OS X resources)
26
TypeTile =
MAKEOSTYPE
(
't'
,
'i'
,
'l'
,
'e'
),
// Container (icon variants)
27
TypeOver =
MAKEOSTYPE
(
'o'
,
'v'
,
'e'
,
'r'
),
// Container (icon variants)
28
TypeOpen =
MAKEOSTYPE
(
'o'
,
'p'
,
'e'
,
'n'
),
// Container (icon variants)
29
TypeDrop =
MAKEOSTYPE
(
'd'
,
'r'
,
'o'
,
'p'
),
// Container (icon variants)
30
TypeOdrp =
MAKEOSTYPE
(
'o'
,
'd'
,
'r'
,
'p'
),
// Container (icon variants)
31
};
32
33
quint32 ostype;
34
quint32 length;
35
};
36
37
struct
ICNSEntry
38
{
39
enum
Group
{
40
GroupUnknown
= 0,
// Default for invalid ones
41
GroupMini
=
'm'
,
// "mini" (16x12)
42
GroupSmall
=
's'
,
// "small" (16x16)
43
GroupLarge
=
'l'
,
// "large" (32x32)
44
GroupHuge
=
'h'
,
// "huge" (48x48)
45
GroupThumbnail
=
't'
,
// "thumbnail" (128x128)
46
GroupPortable
=
'p'
,
// "portable"? (Speculation, used for png/jp2)
47
GroupCompressed
=
'c'
,
// "compressed"? (Speculation, used for png/jp2)
48
// Legacy icons:
49
GroupICON
=
'N'
,
// "ICON" (32x32)
50
};
51
enum
Depth
{
52
DepthUnknown
= 0,
// Default for invalid or compressed ones
53
DepthMono
= 1,
54
Depth4bit
= 4,
55
Depth8bit
= 8,
56
Depth32bit
= 32
57
};
58
enum
Flags
{
59
Unknown
= 0x0,
// Default for invalid ones
60
IsIcon
= 0x1,
// Contains a raw icon without alpha or compressed icon
61
IsMask
= 0x2,
// Contains alpha mask
62
IconPlusMask
=
IsIcon
|
IsMask
// Contains raw icon and mask combined in one entry (double size)
63
};
64
enum
Format
{
65
FormatUnknown
= 0,
// Default for invalid or undetermined ones
66
RawIcon
,
// Raw legacy icon, uncompressed
67
RLE24
,
// Raw 32bit icon, data is compressed
68
PNG
,
// Compressed icon in PNG format
69
JP2
// Compressed icon in JPEG2000 format
70
};
71
72
quint32
ostype
;
// Real OSType
73
quint32
variant
;
// Virtual OSType: a parent container, zero if parent is icns root
74
Group
group
;
// ASCII character number
75
quint32
width
;
// For uncompressed icons only, zero for compressed ones for now
76
quint32
height
;
// For uncompressed icons only, zero for compressed ones fow now
77
Depth
depth
;
// Color depth
78
Flags
flags
;
// Flags to determine the type of entry
79
Format
dataFormat
;
// Format of the image data
80
quint32
dataLength
;
// Length of the image data in bytes
81
qint64
dataOffset
;
// Offset from the initial position of the file/device
82
83
ICNSEntry
() :
84
ostype
(0),
variant
(0),
group
(
GroupUnknown
),
width
(0),
height
(0),
depth
(
DepthUnknown
),
85
flags
(
Unknown
),
dataFormat
(
FormatUnknown
),
dataLength
(0),
dataOffset
(0)
86
{
87
}
88
};
89
Q_DECLARE_TYPEINFO
(
ICNSEntry
,
Q_RELOCATABLE_TYPE
);
90
91
class
QICNSHandler
:
public
QImageIOHandler
92
{
93
public
:
94
QICNSHandler
();
95
96
bool
canRead
()
const
override
;
97
bool
read
(QImage *image)
override
;
98
bool
write
(
const
QImage &image)
override
;
99
100
bool
supportsOption
(ImageOption option)
const
override
;
101
QVariant
option
(ImageOption option)
const
override
;
102
103
int
imageCount
()
const
override
;
104
bool
jumpToImage
(
int
imageNumber)
override
;
105
bool
jumpToNextImage
()
override
;
106
107
static
bool
canRead
(QIODevice *device);
108
109
private
:
110
bool
ensureScanned()
const
;
111
bool
scanDevice();
112
bool
addEntry(
const
ICNSBlockHeader &header, qint64 imgDataOffset, quint32 variant = 0);
113
const
ICNSEntry
&getIconMask(
const
ICNSEntry
&icon)
const
;
114
115
private
:
116
enum
ScanState {
117
ScanError = -1,
118
ScanNotScanned = 0,
119
ScanSuccess = 1,
120
};
121
122
int
m_currentIconIndex;
123
QList<ICNSEntry> m_icons;
124
QList<ICNSEntry> m_masks;
125
ScanState m_state;
126
};
127
128
QT_END_NAMESPACE
129
130
#
endif
// QT_NO_DATASTREAM
131
132
#
endif
/* QICNSHANDLER_P_H */
QICNSHandler
Definition
qicnshandler_p.h:92
QICNSHandler::imageCount
int imageCount() const override
For image formats that support animation, this function returns the number of images in the animation...
Definition
qicnshandler.cpp:805
QICNSHandler::write
bool write(const QImage &image) override
Writes the image image to the assigned device.
Definition
qicnshandler.cpp:730
QICNSHandler::read
bool read(QImage *image) override
Read an image from the device, and stores it in image.
Definition
qicnshandler.cpp:667
QICNSHandler::canRead
bool canRead() const override
Returns true if an image can be read from the device (i.e., the image format is supported,...
Definition
qicnshandler.cpp:654
QICNSHandler::supportsOption
bool supportsOption(ImageOption option) const override
Returns true if the QImageIOHandler supports the option option; otherwise returns false.
Definition
qicnshandler.cpp:783
QICNSHandler::option
QVariant option(ImageOption option) const override
Returns the value assigned to option as a QVariant.
Definition
qicnshandler.cpp:788
QICNSHandler::jumpToImage
bool jumpToImage(int imageNumber) override
For image formats that support animation, this function jumps to the image whose sequence number is i...
Definition
qicnshandler.cpp:813
QICNSHandler::jumpToNextImage
bool jumpToNextImage() override
For image formats that support animation, this function jumps to the next image.
Definition
qicnshandler.cpp:822
QICNSHandler::canRead
static bool canRead(QIODevice *device)
Definition
qicnshandler.cpp:636
QICNSHandler::QICNSHandler
QICNSHandler()
Definition
qicnshandler.cpp:631
QICNSPlugin
Definition
main.cpp:16
QICNSPlugin::create
QImageIOHandler * create(QIODevice *device, const QByteArray &format=QByteArray()) const override
Creates and returns a QImageIOHandler subclass, with device and format set.
Definition
main.cpp:42
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
MAKEOSTYPE
#define MAKEOSTYPE(c0, c1, c2, c3)
Definition
qicnshandler_p.h:14
Q_DECLARE_TYPEINFO
Q_DECLARE_TYPEINFO(ICNSEntry, Q_RELOCATABLE_TYPE)
ICNSEntry
Definition
qicnshandler_p.h:38
ICNSEntry::Flags
Flags
Definition
qicnshandler_p.h:58
ICNSEntry::IsMask
@ IsMask
Definition
qicnshandler_p.h:61
ICNSEntry::Unknown
@ Unknown
Definition
qicnshandler_p.h:59
ICNSEntry::IconPlusMask
@ IconPlusMask
Definition
qicnshandler_p.h:62
ICNSEntry::IsIcon
@ IsIcon
Definition
qicnshandler_p.h:60
ICNSEntry::height
quint32 height
Definition
qicnshandler_p.h:76
ICNSEntry::ICNSEntry
ICNSEntry()
Definition
qicnshandler_p.h:83
ICNSEntry::width
quint32 width
Definition
qicnshandler_p.h:75
ICNSEntry::depth
Depth depth
Definition
qicnshandler_p.h:77
ICNSEntry::dataOffset
qint64 dataOffset
Definition
qicnshandler_p.h:81
ICNSEntry::Depth
Depth
Definition
qicnshandler_p.h:51
ICNSEntry::Depth8bit
@ Depth8bit
Definition
qicnshandler_p.h:55
ICNSEntry::Depth4bit
@ Depth4bit
Definition
qicnshandler_p.h:54
ICNSEntry::DepthMono
@ DepthMono
Definition
qicnshandler_p.h:53
ICNSEntry::Depth32bit
@ Depth32bit
Definition
qicnshandler_p.h:56
ICNSEntry::DepthUnknown
@ DepthUnknown
Definition
qicnshandler_p.h:52
ICNSEntry::dataLength
quint32 dataLength
Definition
qicnshandler_p.h:80
ICNSEntry::variant
quint32 variant
Definition
qicnshandler_p.h:73
ICNSEntry::Group
Group
Definition
qicnshandler_p.h:39
ICNSEntry::GroupSmall
@ GroupSmall
Definition
qicnshandler_p.h:42
ICNSEntry::GroupPortable
@ GroupPortable
Definition
qicnshandler_p.h:46
ICNSEntry::GroupICON
@ GroupICON
Definition
qicnshandler_p.h:49
ICNSEntry::GroupCompressed
@ GroupCompressed
Definition
qicnshandler_p.h:47
ICNSEntry::GroupLarge
@ GroupLarge
Definition
qicnshandler_p.h:43
ICNSEntry::GroupHuge
@ GroupHuge
Definition
qicnshandler_p.h:44
ICNSEntry::GroupThumbnail
@ GroupThumbnail
Definition
qicnshandler_p.h:45
ICNSEntry::GroupMini
@ GroupMini
Definition
qicnshandler_p.h:41
ICNSEntry::GroupUnknown
@ GroupUnknown
Definition
qicnshandler_p.h:40
ICNSEntry::dataFormat
Format dataFormat
Definition
qicnshandler_p.h:79
ICNSEntry::group
Group group
Definition
qicnshandler_p.h:74
ICNSEntry::flags
Flags flags
Definition
qicnshandler_p.h:78
ICNSEntry::Format
Format
Definition
qicnshandler_p.h:64
ICNSEntry::RLE24
@ RLE24
Definition
qicnshandler_p.h:67
ICNSEntry::PNG
@ PNG
Definition
qicnshandler_p.h:68
ICNSEntry::JP2
@ JP2
Definition
qicnshandler_p.h:69
ICNSEntry::FormatUnknown
@ FormatUnknown
Definition
qicnshandler_p.h:65
ICNSEntry::RawIcon
@ RawIcon
Definition
qicnshandler_p.h:66
ICNSEntry::ostype
quint32 ostype
Definition
qicnshandler_p.h:72
qtimageformats
src
plugins
imageformats
icns
qicnshandler_p.h
Generated on
for Qt by
1.18.0