-
Notifications
You must be signed in to change notification settings - Fork 0
/
bmp16.h
80 lines (68 loc) · 1.4 KB
/
bmp16.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#ifndef BMP16_H
#define BMP16_H
typedef struct header
{
short id;
int size;
short non1;
short non2;
int pixel_array_offset;
}bmp_header;
typedef struct pixel
{
unsigned char r;
unsigned char g;
unsigned char b;
}bmp16_pixel;
typedef struct dib
{
int width;
int height;
short col_planes;
short bits;
int bi_rgb;
int raw_size;
int dpi_horizontal;
int dpi_vertical;
int col_palette;
int col_important;
}bmp16_dib;
/*
The pixel array should be a seperate structure
so the get_pixel and set_pixel work independently
from the bmp structure.
*/
typedef struct bmp
{
bmp_header header;
int dib_size;
bmp16_dib dib;
bmp16_pixel* pixels;
int pixel_count;
int pad;
} bmp16;
/**
* Creates a new bmp16 structure with predefined header and dib sections.
* */
bmp16* bmp16_create_new(int width, int height);
/**
* Reads a bmp16 file on a single pass.
* */
bmp16* bmp16_single_read(const char* file);
/**
* Returns the nex pixel from preloaded bmp file.
* */
bmp16_pixel bmp16_get_pixel(unsigned char** data);
/**
* Save a bmp file on the given path.
* */
void bmp16_save(bmp16* bmp, char* path);
/**
* Get a pixel at a given (x, y) location (bottom left corner oriented).
* */
bmp16_pixel bmp16_get_pixel_at(bmp16* bmp, int i, int j);
/**
* Set a pixel at a given (x, y) location (bottom left corner oriented).
* */
void bmp16_set_pixel_at(bmp16* bmp, bmp16_pixel pixel, int i, int j);
#endif