Krita Source Code Documentation
Loading...
Searching...
No Matches
tga.h
Go to the documentation of this file.
1
/* This file is part of the KDE project
2
SPDX-FileCopyrightText: 2003 Dominik Seichter <domseichter@web.de>
3
SPDX-FileCopyrightText: 2004 Ignacio CastaƱo <castano@ludicon.com>
4
5
SPDX-License-Identifier: LGPL-2.0-or-later
6
*/
7
8
/* this code supports:
9
* reading:
10
* uncompressed and run length encoded indexed, grey and color tga files.
11
* image types 1, 2, 3, 9, 10 and 11.
12
* only RGB color maps with no more than 256 colors.
13
* pixel formats 8, 15, 24 and 32.
14
* writing:
15
* uncompressed true color tga files
16
*/
17
#ifndef TGA_H
18
#define TGA_H
19
20
#include <QDataStream>
21
#include <QColor>
22
23
// Header format of saved files.
24
const
uchar
targaMagic
[12] = { 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
25
26
enum
TGAType
{
27
TGA_TYPE_INDEXED
= 1,
28
TGA_TYPE_RGB
= 2,
29
TGA_TYPE_GREY
= 3,
30
TGA_TYPE_RLE_INDEXED
= 9,
31
TGA_TYPE_RLE_RGB
= 10,
32
TGA_TYPE_RLE_GREY
= 11
33
};
34
35
#define TGA_INTERLEAVE_MASK 0xc0
36
#define TGA_INTERLEAVE_NONE 0x00
37
#define TGA_INTERLEAVE_2WAY 0x40
38
#define TGA_INTERLEAVE_4WAY 0x80
39
40
#define TGA_ORIGIN_MASK 0x30
41
#define TGA_ORIGIN_LEFT 0x00
42
#define TGA_ORIGIN_RIGHT 0x10
43
#define TGA_ORIGIN_LOWER 0x00
44
#define TGA_ORIGIN_UPPER 0x20
45
47
struct
TgaHeader
{
48
uchar
id_length
;
49
uchar
colormap_type
;
50
uchar
image_type
;
51
ushort
colormap_index
;
52
ushort
colormap_length
;
53
uchar
colormap_size
;
54
ushort
x_origin
;
55
ushort
y_origin
;
56
ushort
width
;
57
ushort
height
;
58
uchar
pixel_size
;
59
uchar
flags
;
60
61
enum
{
SIZE
= 18 };
// const static int SIZE = 18;
62
};
63
64
65
struct
Color555
{
66
ushort
b
: 5;
67
ushort
g
: 5;
68
ushort
r
: 5;
69
};
70
71
struct
TgaHeaderInfo
{
72
bool
rle
;
73
bool
pal
;
74
bool
rgb
;
75
bool
grey
;
76
77
TgaHeaderInfo
(
const
TgaHeader
& tga) :
rle
(false),
pal
(false),
rgb
(false),
grey
(false) {
78
switch
(tga.
image_type
) {
79
case
TGA_TYPE_RLE_INDEXED
:
80
rle
=
true
;
81
Q_FALLTHROUGH();
82
case
TGA_TYPE_INDEXED
:
83
pal
=
true
;
84
break
;
85
86
case
TGA_TYPE_RLE_RGB
:
87
rle
=
true
;
88
Q_FALLTHROUGH();
89
case
TGA_TYPE_RGB
:
90
rgb
=
true
;
91
break
;
92
case
TGA_TYPE_RLE_GREY
:
93
rle
=
true
;
94
Q_FALLTHROUGH();
95
case
TGA_TYPE_GREY
:
96
grey
=
true
;
97
break
;
98
default
:
99
// Error, unknown image type.
100
break
;
101
}
102
}
103
};
104
105
106
107
108
109
110
#endif
// TGA_H
Color555
Definition
tga.h:65
Color555::b
ushort b
Definition
tga.h:66
Color555::r
ushort r
Definition
tga.h:68
Color555::g
ushort g
Definition
tga.h:67
TgaHeaderInfo
Definition
tga.h:71
TgaHeaderInfo::pal
bool pal
Definition
tga.h:73
TgaHeaderInfo::TgaHeaderInfo
TgaHeaderInfo(const TgaHeader &tga)
Definition
tga.h:77
TgaHeaderInfo::rle
bool rle
Definition
tga.h:72
TgaHeaderInfo::rgb
bool rgb
Definition
tga.h:74
TgaHeaderInfo::grey
bool grey
Definition
tga.h:75
TgaHeader
Definition
tga.h:47
TgaHeader::colormap_length
ushort colormap_length
Definition
tga.h:52
TgaHeader::id_length
uchar id_length
Definition
tga.h:48
TgaHeader::colormap_size
uchar colormap_size
Definition
tga.h:53
TgaHeader::SIZE
@ SIZE
Definition
tga.h:61
TgaHeader::height
ushort height
Definition
tga.h:57
TgaHeader::pixel_size
uchar pixel_size
Definition
tga.h:58
TgaHeader::colormap_index
ushort colormap_index
Definition
tga.h:51
TgaHeader::y_origin
ushort y_origin
Definition
tga.h:55
TgaHeader::width
ushort width
Definition
tga.h:56
TgaHeader::colormap_type
uchar colormap_type
Definition
tga.h:49
TgaHeader::image_type
uchar image_type
Definition
tga.h:50
TgaHeader::flags
uchar flags
Definition
tga.h:59
TgaHeader::x_origin
ushort x_origin
Definition
tga.h:54
targaMagic
const uchar targaMagic[12]
Definition
tga.h:24
TGAType
TGAType
Definition
tga.h:26
TGA_TYPE_GREY
@ TGA_TYPE_GREY
Definition
tga.h:29
TGA_TYPE_INDEXED
@ TGA_TYPE_INDEXED
Definition
tga.h:27
TGA_TYPE_RGB
@ TGA_TYPE_RGB
Definition
tga.h:28
TGA_TYPE_RLE_RGB
@ TGA_TYPE_RLE_RGB
Definition
tga.h:31
TGA_TYPE_RLE_GREY
@ TGA_TYPE_RLE_GREY
Definition
tga.h:32
TGA_TYPE_RLE_INDEXED
@ TGA_TYPE_RLE_INDEXED
Definition
tga.h:30
plugins
impex
tga
tga.h
Generated at
2025-11-04 02:30:02+01:00
from
Krita
branch
master
, commit
c9dde2e79561a8aea4a7e8d9ac99c98a7bac9e52