Skip to content

Commit 8f04bcc

Browse files
feat: add bmp.h header for image structure definitions
1 parent b5af0e5 commit 8f04bcc

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"C_Cpp.errorSquiggles": "disabled"
3+
}

bmp.h

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// BMP-related data types based on Microsoft's own
2+
3+
#include <stdint.h>
4+
5+
// These data types are essentially aliases for C/C++ primitive data types.
6+
// Adapted from http://msdn.microsoft.com/en-us/library/cc230309.aspx.
7+
// See https://en.wikipedia.org/wiki/C_data_types#stdint.h for more on stdint.h.
8+
9+
typedef uint8_t BYTE;
10+
typedef uint32_t DWORD;
11+
typedef int32_t LONG;
12+
typedef uint16_t WORD;
13+
14+
// The BITMAPFILEHEADER structure contains information about the type, size,
15+
// and layout of a file that contains a DIB [device-independent bitmap].
16+
// Adapted from http://msdn.microsoft.com/en-us/library/dd183374(VS.85).aspx.
17+
18+
typedef struct
19+
{
20+
WORD bfType;
21+
DWORD bfSize;
22+
WORD bfReserved1;
23+
WORD bfReserved2;
24+
DWORD bfOffBits;
25+
} __attribute__((__packed__))
26+
BITMAPFILEHEADER;
27+
28+
// The BITMAPINFOHEADER structure contains information about the
29+
// dimensions and color format of a DIB [device-independent bitmap].
30+
// Adapted from http://msdn.microsoft.com/en-us/library/dd183376(VS.85).aspx.
31+
32+
typedef struct
33+
{
34+
DWORD biSize;
35+
LONG biWidth;
36+
LONG biHeight;
37+
WORD biPlanes;
38+
WORD biBitCount;
39+
DWORD biCompression;
40+
DWORD biSizeImage;
41+
LONG biXPelsPerMeter;
42+
LONG biYPelsPerMeter;
43+
DWORD biClrUsed;
44+
DWORD biClrImportant;
45+
} __attribute__((__packed__))
46+
BITMAPINFOHEADER;
47+
48+
// The RGBTRIPLE structure describes a color consisting of relative intensities of
49+
// red, green, and blue. Adapted from http://msdn.microsoft.com/en-us/library/aa922590.aspx.
50+
51+
typedef struct
52+
{
53+
BYTE rgbtBlue;
54+
BYTE rgbtGreen;
55+
BYTE rgbtRed;
56+
} __attribute__((__packed__))
57+
RGBTRIPLE;

0 commit comments

Comments
 (0)