-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTGAImage.h
52 lines (43 loc) · 1.1 KB
/
TGAImage.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
#pragma once
#include <string>
#include <vector>
#include <fstream>
#pragma pack(push, 1)
struct TGAHeader
{
unsigned char idLength;
unsigned char colourMapType;
unsigned char dataTypeCode;
unsigned short colourMapOrigin;
unsigned short colourMapLength;
unsigned char colourMapDepth;
unsigned short xOrigin;
unsigned short yOrigin;
unsigned short width;
unsigned short height;
unsigned char bitsPerPixel;
unsigned char imageDescriptor;
};
#pragma pack(pop)
struct TGAFooter
{
unsigned short extOffset;
unsigned short dev;
char signature[18];
};
class TGAImage
{
unsigned char* m_imageData;
unsigned int m_height, m_width;
unsigned int m_bitsPerPixel;
int m_imageSize;
public:
TGAImage();
~TGAImage();
unsigned char* GetImageData() { return m_imageData; }
unsigned int GetHeight() {return m_height;}
unsigned int GetWidth() {return m_width;}
int GetImageSize() { return m_imageSize; }
static bool Save(std::string fileName, unsigned char* imageData, int width, int height, int bpp);
bool Load(std::string fileName);
};