-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbmp.h
62 lines (50 loc) · 1.14 KB
/
bmp.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
// bmp.h
#ifndef BMP_H
#define BMP_H
#include <stdint.h>
#include <stdbool.h>
typedef struct {
uint8_t r;
uint8_t g;
uint8_t b;
} color_16bpp_t;
typedef struct {
uint8_t r;
uint8_t g;
uint8_t b;
} color_24bpp_t;
typedef struct {
uint8_t r;
uint8_t g;
uint8_t b;
uint8_t a;
} color_32bpp_t;
typedef struct {
uint32_t width;
uint32_t height;
uint16_t color_depth;
void* data; // Cast into color_16/24/32bpp_t
} bmp_t;
typedef enum {
NO_ERROR = 0,
INVALID_DEPTH,
NULL_PTR_ERROR,
INVALID_FILE,
INVALID_SIZE,
INVALID_INFOHEADER,
INVALID_COMPRESSION,
DATA_EXISTS,
OUT_OF_MEMORY
} bmp_error_t;
typedef enum {
LEFT = 0,
RIGHT
} bmp_rotation_direction_t;
extern const char* bmp_error_strings[];
bmp_error_t bmp_init(bmp_t* bmp);
bmp_error_t bmp_init_data(bmp_t* bmp, uint16_t width, uint16_t height, uint8_t color_depth);
bmp_error_t bmp_rotate(bmp_t* bmp, bmp_rotation_direction_t direction);
bmp_error_t bmp_destroy(bmp_t* bmp);
bmp_error_t bmp_openfile(bmp_t* bmp, const char* filepath);
bmp_error_t bmp_save(bmp_t* bmp, const char* filepath);
#endif // BMP_H