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.
24const uchar targaMagic[12] = { 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
25
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
47struct TgaHeader {
48 uchar id_length;
54 ushort x_origin;
55 ushort y_origin;
56 ushort width;
57 ushort height;
59 uchar flags;
60
61 enum { SIZE = 18 }; // const static int SIZE = 18;
62};
63
64
65struct Color555 {
66 ushort b : 5;
67 ushort g : 5;
68 ushort r : 5;
69};
70
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) {
80 rle = true;
81 Q_FALLTHROUGH();
83 pal = true;
84 break;
85
87 rle = true;
88 Q_FALLTHROUGH();
89 case TGA_TYPE_RGB:
90 rgb = true;
91 break;
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
Definition tga.h:65
ushort b
Definition tga.h:66
ushort r
Definition tga.h:68
ushort g
Definition tga.h:67
bool pal
Definition tga.h:73
TgaHeaderInfo(const TgaHeader &tga)
Definition tga.h:77
bool rle
Definition tga.h:72
bool rgb
Definition tga.h:74
bool grey
Definition tga.h:75
ushort colormap_length
Definition tga.h:52
uchar id_length
Definition tga.h:48
uchar colormap_size
Definition tga.h:53
@ SIZE
Definition tga.h:61
ushort height
Definition tga.h:57
uchar pixel_size
Definition tga.h:58
ushort colormap_index
Definition tga.h:51
ushort y_origin
Definition tga.h:55
ushort width
Definition tga.h:56
uchar colormap_type
Definition tga.h:49
uchar image_type
Definition tga.h:50
uchar flags
Definition tga.h:59
ushort x_origin
Definition tga.h:54
const uchar targaMagic[12]
Definition tga.h:24
TGAType
Definition tga.h:26
@ TGA_TYPE_GREY
Definition tga.h:29
@ TGA_TYPE_INDEXED
Definition tga.h:27
@ TGA_TYPE_RGB
Definition tga.h:28
@ TGA_TYPE_RLE_RGB
Definition tga.h:31
@ TGA_TYPE_RLE_GREY
Definition tga.h:32
@ TGA_TYPE_RLE_INDEXED
Definition tga.h:30