-
Notifications
You must be signed in to change notification settings - Fork 0
/
tga.h
63 lines (49 loc) · 1.4 KB
/
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef TGA_H
#define TGA_H
#include <fstream>
class tgaFile
{
struct TGA_HEADER
{
char identsize; // size of ID field that follows 18 byte header (0 usually)
char colourmaptype; // type of colour map 0=none, 1=has palette
char imagetype; // type of image 0=none,1=indexed,2=rgb,3=grey,+8=rle packed
short colourmapstart; // first colour map entry in palette
short colourmaplength; // number of colours in palette
char colourmapbits; // number of bits per palette entry 15,16,24,32
short xstart; // image x origin
short ystart; // image y origin
short width; // image width in pixels
short height; // image height in pixels
char bits; // image bits per pixel 8,16,24,32
char descriptor; // image descriptor bits (vh flip bits)
// pixel data follows header
};
struct TGA_RGBA
{
char R;
char G;
char B;
char A;
};
struct TGA_RGB
{
char R;
char G;
char B;
};
char filename[256];
std::ifstream inFile;
unsigned char byteCount;
unsigned char *data;
public:
tgaFile(char *path);
tgaFile();
~tgaFile();
TGA_HEADER header;
bool readHeader();
bool readData();
unsigned char getByteCount() { return byteCount; };
unsigned char * getData() { return data; };
};
#endif // TGA_H