-
Notifications
You must be signed in to change notification settings - Fork 0
/
BMPLoader.h
50 lines (44 loc) · 885 Bytes
/
BMPLoader.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
#ifndef BMP_LOADER_H
#define BMP_LOADER_H
#include <cstdint>
#include <string>
#pragma pack(push, 1)
struct bmp_header_t {
int16_t type;
uint32_t filesize;
int32_t reserved;
uint32_t offset;
};
struct bmp_image_header_t {
uint32_t headerSize;
int32_t width;
int32_t height;
uint16_t planes;
uint16_t bits;
uint32_t compression;
uint32_t imageSize;
int32_t xppm;
int32_t yppm;
uint32_t totalColors;
uint32_t importantColors;
};
#pragma pack(pop)
#define BMP_PALETTE_SIZE 0xFF
class BMP {
private:
bmp_header_t header;
bmp_image_header_t imageHeader;
uint32_t colors[BMP_PALETTE_SIZE];
void* pixels;
public:
BMP();
BMP(int32_t width, int32_t height, uint16_t bits);
~BMP();
void Load(std::string path);
int32_t GetWidth() const;
int32_t GetHeight() const;
uint16_t GetBits() const;
void* GetData();
void SetPixel(int x, int y, uint32_t pixel);
};
#endif