-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbmpload.h
More file actions
106 lines (88 loc) · 2.58 KB
/
bmpload.h
File metadata and controls
106 lines (88 loc) · 2.58 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#pragma once
#include <stdint.h>
#ifdef _WIN32
// grrrrrrrrrrrrr......
#define WIN32_LEAN_AND_MEAN
#define NOMINMAX
#include <windows.h>
#else
// ripped from wingdi.h blabla
#pragma pack(push, 1)
typedef struct tagBITMAPFILEHEADER {
uint16_t bfType;
uint32_t bfSize;
uint16_t bfReserved1;
uint16_t bfReserved2;
uint32_t bfOffBits;
} BITMAPFILEHEADER;
typedef struct tagBITMAPINFOHEADER {
uint32_t biSize;
int32_t biWidth;
int32_t biHeight;
uint16_t biPlanes;
uint16_t biBitCount;
uint32_t biCompression;
uint32_t biSizeImage;
int32_t biXPelsPerMeter;
int32_t biYPelsPerMeter;
uint32_t biClrUsed;
uint32_t biClrImportant;
} BITMAPINFOHEADER;
// GRRRRRRRRRRRRRRRRRRRRRRRRRR
typedef struct tagCIEXYZ {
int32_t ciexyzX; // 2.30fx
int32_t ciexyzY;
int32_t ciexyzZ;
} CIEXYZ;
typedef struct tagICEXYZTRIPLE {
CIEXYZ ciexyzRed;
CIEXYZ ciexyzGreen;
CIEXYZ ciexyzBlue;
} CIEXYZTRIPLE;
// BITMAPINFOHEADER::biCompression flags
enum {
BI_RGB = 0,
BI_RLE8 = 1,
BI_RLE4 = 2,
BI_BITFIELDS = 3,
BI_JPEG = 4,
BI_PNG = 5,
BI_ALPHABITFIELDS = 6,
};
#endif
typedef struct {
uint32_t bV5Size;
int32_t bV5Width;
int32_t bV5Height;
uint16_t bV5Planes;
uint16_t bV5BitCount;
uint32_t bV5Compression;
uint32_t bV5SizeImage;
int32_t bV5XPelsPerMeter;
int32_t bV5YPelsPerMeter;
uint32_t bV5ClrUsed;
uint32_t bV5ClrImportant;
uint32_t bV5RedMask;
uint32_t bV5GreenMask;
uint32_t bV5BlueMask;
uint32_t bV5AlphaMask;
uint32_t bV5CSType;
CIEXYZTRIPLE bV5Endpoints;
uint32_t bV5GammaRed;
uint32_t bV5GammaGreen;
uint32_t bV5GammaBlue;
uint32_t bV5Intent;
uint32_t bV5ProfileData;
uint32_t bV5ProfileSize;
uint32_t bV5Reserved;
} BITMAPV5HEADER;
#pragma pack(pop)
// 32bpp
int bmp_load_header(const char *fname, BITMAPV5HEADER *head);
int bmp_load_data(const char *fname, BITMAPV5HEADER *head, uint32_t *buf, int order, uint32_t pitch = 0);
// 15/16bpp
int bmp_load16_header(const char *fname, BITMAPV5HEADER *head);
int bmp_load16_data(const char *fname, BITMAPV5HEADER *head, uint16_t *buf, int order, uint32_t pitch = 0);
// 8bpp
int bmp_load8_header(const char *fname, BITMAPV5HEADER *head);
int bmp_load8_data(const char *fname, BITMAPV5HEADER *head, uint8_t *buf, uint32_t *pal, int order, uint32_t pitch = 0);