-
Notifications
You must be signed in to change notification settings - Fork 6
/
tga.h
34 lines (32 loc) · 887 Bytes
/
tga.h
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
typedef struct {
char idlength;
char colourmaptype;
char datatypecode;
short int colourmaporigin;
short int colourmaplength;
char colourmapdepth;
short int x_origin;
short int y_origin;
short width;
short height;
char bitsperpixel;
char imagedescriptor;
} __attribute__((packed)) TgaHeader;
typedef enum {
UncompressedRGB = 2,
UncompressedGrayscale = 3
} TgaType;
void setupTgaHeader(TgaHeader* header, TgaType type, unsigned short width, unsigned short height) {
header->idlength = 0;
header->colourmaptype = 0;
header->datatypecode = type;
header->colourmaporigin = 0;
header->colourmaplength = 0;
header->colourmapdepth = 0;
header->x_origin = 0;
header->y_origin = 0;
header->width = width;
header->height = height;
header->bitsperpixel = (type == UncompressedRGB ? 32 : 8);
header->imagedescriptor = 1 << 5;
}