-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbmp.h
50 lines (44 loc) · 1.03 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
#pragma once
#include <stdint.h>
// https://en.wikipedia.org/wiki/BMP_file_format
typedef struct{
char name[2]; // 1+1 Bytes
uint32_t size; // 4 Bytes
int32_t junk; // 2+2 Bytes
uint32_t offset; // 4 Bytes
} BMPHEADER;
typedef struct{
uint32_t header_size; // 4 Bytes
int32_t width; // 4 Bytes
int32_t height; // 4 Bytes
uint16_t color_panes; // 2 Bytes
uint16_t bit_depth; // 2 Bytes
uint32_t compression; // 4 Bytes
uint32_t image_size; // 4 Bytes
int32_t hres; // 4 Bytes
int32_t vres; // 4 Bytes
uint32_t number_colors; // 4 Bytes
uint32_t number_important_colors; // 4 Bytes
} DIBHEADER;
// unsigned char is 8 bits (0-255)
typedef struct{
unsigned char B;
unsigned char G;
unsigned char R;
} RGB;
typedef struct{
unsigned char B;
unsigned char G;
unsigned char R;
unsigned char A;
} RGBA;
typedef struct{
RGB ** pixels;
int32_t width;
int32_t height;
} IMAGE;
typedef struct{
RGBA ** pixels;
int32_t width;
int32_t height;
} IMAGE32;