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
qtgafile.h
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
#
ifndef
QTGAFILE_H
6
#
define
QTGAFILE_H
7
8
#
include
<
QtGui
/
QColor
>
9
#
include
<
QtGui
/
QImage
>
10
#
include
<
QtCore
/
QCoreApplication
>
11
12
QT_BEGIN_NAMESPACE
13
14
class
QIODevice;
15
16
class
QTgaFile
17
{
18
Q_DECLARE_TR_FUNCTIONS
(
QTgaFile
)
19
20
public
:
21
enum
Compression
{
22
NoCompression
= 0,
23
RleCompression
= 1
24
};
25
26
enum
HeaderOffset
{
27
IdLength
= 0,
/* 00h Size of Image ID field */
28
ColorMapType
= 1,
/* 01h Color map type */
29
ImageType
= 2,
/* 02h Image type code */
30
CMapStart
= 3,
/* 03h Color map origin */
31
CMapLength
= 5,
/* 05h Color map length */
32
CMapDepth
= 7,
/* 07h Depth of color map entries */
33
XOffset
= 8,
/* 08h X origin of image */
34
YOffset
= 10,
/* 0Ah Y origin of image */
35
Width
= 12,
/* 0Ch Width of image */
36
Height
= 14,
/* 0Eh Height of image */
37
PixelDepth
= 16,
/* 10h Image pixel size */
38
ImageDescriptor
= 17,
/* 11h Image descriptor byte */
39
HeaderSize
= 18
40
};
41
42
enum
FooterOffset
{
43
ExtensionOffset
= 0,
44
DeveloperOffset
= 4,
45
SignatureOffset
= 8,
46
FooterSize
= 26
47
};
48
49
QTgaFile
(QIODevice *);
50
~
QTgaFile
();
51
52
inline
bool
isValid
()
const
;
53
inline
QString
errorMessage
()
const
;
54
QImage
readImage
();
55
inline
int
xOffset
()
const
;
56
inline
int
yOffset
()
const
;
57
inline
int
width
()
const
;
58
inline
int
height
()
const
;
59
inline
QSize
size
()
const
;
60
inline
Compression
compression
()
const
;
61
62
private
:
63
static
inline
quint16 littleEndianInt(
const
unsigned
char
*d);
64
65
QString mErrorMessage;
66
unsigned
char
mHeader[
HeaderSize
];
67
QIODevice *mDevice;
68
};
69
70
inline
bool
QTgaFile
::
isValid
()
const
71
{
72
return
mErrorMessage.isEmpty();
73
}
74
75
inline
QString
QTgaFile
::
errorMessage
()
const
76
{
77
return
mErrorMessage;
78
}
79
80
/*!
81
\internal
82
Returns the integer encoded in the two little endian bytes at \a d.
83
*/
84
inline
quint16
QTgaFile
::littleEndianInt(
const
unsigned
char
*d)
85
{
86
return
d[0] + d[1] * 256;
87
}
88
89
inline
int
QTgaFile
::
xOffset
()
const
90
{
91
return
littleEndianInt(&mHeader[XOffset]);
92
}
93
94
inline
int
QTgaFile
::
yOffset
()
const
95
{
96
return
littleEndianInt(&mHeader[YOffset]);
97
}
98
99
inline
int
QTgaFile
::
width
()
const
100
{
101
return
littleEndianInt(&mHeader[Width]);
102
}
103
104
inline
int
QTgaFile
::
height
()
const
105
{
106
return
littleEndianInt(&mHeader[Height]);
107
}
108
109
inline
QSize
QTgaFile
::
size
()
const
110
{
111
return
QSize(
width
(
)
,
height
(
)
);
112
}
113
114
inline
QTgaFile
::
Compression
QTgaFile
::
compression
()
const
115
{
116
// TODO: for now, only handle type 2 files, with no color table
117
// and no compression
118
return
NoCompression;
119
}
120
121
QT_END_NAMESPACE
122
123
#
endif
// QTGAFILE_H
QTgaFile
Definition
qtgafile.h:17
QTgaFile::isValid
bool isValid() const
Definition
qtgafile.h:70
QTgaFile::FooterOffset
FooterOffset
Definition
qtgafile.h:42
QTgaFile::SignatureOffset
@ SignatureOffset
Definition
qtgafile.h:45
QTgaFile::DeveloperOffset
@ DeveloperOffset
Definition
qtgafile.h:44
QTgaFile::FooterSize
@ FooterSize
Definition
qtgafile.h:46
QTgaFile::ExtensionOffset
@ ExtensionOffset
Definition
qtgafile.h:43
QTgaFile::size
QSize size() const
Definition
qtgafile.h:109
QTgaFile::yOffset
int yOffset() const
Definition
qtgafile.h:94
QTgaFile::width
int width() const
Definition
qtgafile.h:99
QTgaFile::QTgaFile
QTgaFile(QIODevice *)
Construct a new QTgaFile object getting data from device.
Definition
qtgafile.cpp:102
QTgaFile::errorMessage
QString errorMessage() const
Definition
qtgafile.h:75
QTgaFile::height
int height() const
Definition
qtgafile.h:104
QTgaFile::HeaderOffset
HeaderOffset
Definition
qtgafile.h:26
QTgaFile::Height
@ Height
Definition
qtgafile.h:36
QTgaFile::ColorMapType
@ ColorMapType
Definition
qtgafile.h:28
QTgaFile::CMapDepth
@ CMapDepth
Definition
qtgafile.h:32
QTgaFile::IdLength
@ IdLength
Definition
qtgafile.h:27
QTgaFile::CMapLength
@ CMapLength
Definition
qtgafile.h:31
QTgaFile::ImageDescriptor
@ ImageDescriptor
Definition
qtgafile.h:38
QTgaFile::YOffset
@ YOffset
Definition
qtgafile.h:34
QTgaFile::Width
@ Width
Definition
qtgafile.h:35
QTgaFile::PixelDepth
@ PixelDepth
Definition
qtgafile.h:37
QTgaFile::CMapStart
@ CMapStart
Definition
qtgafile.h:30
QTgaFile::HeaderSize
@ HeaderSize
Definition
qtgafile.h:39
QTgaFile::ImageType
@ ImageType
Definition
qtgafile.h:29
QTgaFile::XOffset
@ XOffset
Definition
qtgafile.h:33
QTgaFile::~QTgaFile
~QTgaFile()
Definition
qtgafile.cpp:168
QTgaFile::compression
Compression compression() const
Definition
qtgafile.h:114
QTgaFile::readImage
QImage readImage()
Definition
qtgafile.cpp:186
QTgaFile::xOffset
int xOffset() const
Definition
qtgafile.h:89
qtimageformats
src
plugins
imageformats
tga
qtgafile.h
Generated on
for Qt by
1.14.0