-
Notifications
You must be signed in to change notification settings - Fork 4
/
GraphicBaseFile.h
66 lines (54 loc) · 1.22 KB
/
GraphicBaseFile.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
64
65
66
#ifndef GRAPHICBASEFILE_H
#define GRAPHICBASEFILE_H
#include "types.h"
#include <iostream>
#include <sstream>
#include <fstream>
#ifdef WIN32
#include <SDL.h>
#else
#include <SDL2/SDL.h>
#endif
namespace SCRANTIC {
struct BitmapFileHeader {
u16 bfType;
u32 bfSize;
u32 bfReserved;
u32 bfOffsetBits;
};
struct BitmapInfoHeader {
u32 biSize;
i32 biWidth;
i32 biHeight;
u16 biPlanes;
u16 biBitCount;
u32 biCompression;
u32 biSizeImage;
i32 biXPelsPerMeter;
i32 biYPelsPerMeter;
u32 biClrUsed;
u32 biClrImportant;
u32 biRedMask;
u32 biGreenMask;
u32 biBlueMask;
u32 biAlphaMask;
u32 biColourSpace;
u32 biCsEndpoints[9];
u32 biRedGamma;
u32 biGreenGamma;
u32 biBlueGamma;
};
class GraphicBaseFile {
private:
i8 matchSdlColorToPaletteNumber(SDL_Color &color);
protected:
SDL_Surface* createSdlSurface(v8 &data, u16 width, u16 height, size_t offset = 0);
v8 createRGBABitmapData(v8 &data, u16 width, u16 height, size_t offset = 0);
v8 readRGBABitmapData(const std::string &filename, u16 &width, u16 &height);
SDL_Color defaultPalette[256];
public:
GraphicBaseFile();
~GraphicBaseFile() {};
};
}
#endif // GRAPHICBASEFILE_H