Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1789 | yogev_ezra | 1 | // |
2 | // bmp.h - header file / freeware |
||
3 | // |
||
4 | // David Henry - tfc_duke@hotmail.com |
||
5 | // |
||
6 | |||
7 | #ifndef __BITMAP_H_ |
||
8 | #define __BITMAP_H_ |
||
9 | |||
10 | |||
11 | |||
12 | // magic number "BM" |
||
13 | #define BITMAP_ID ('B' + ('M'<<8)) |
||
14 | |||
15 | |||
16 | |||
17 | // header byte type for RLE |
||
18 | #define RLE_COMMAND 0 |
||
19 | #define RLE_ENDOFLINE 0 |
||
20 | #define RLE_ENDOFBITMAP 1 |
||
21 | #define RLE_DELTA 2 |
||
22 | |||
23 | #define BI_OS2 -1 |
||
24 | |||
25 | |||
26 | // compression type |
||
27 | #define BI_RGB 0 |
||
28 | #define BI_RLE8 1 |
||
29 | #define BI_RLE4 2 |
||
30 | #define BI_BITFIELDS 3 |
||
31 | |||
32 | |||
33 | |||
34 | #pragma warning( disable : 4103 ) |
||
35 | |||
36 | |||
37 | |||
38 | // -------------------------------------------- |
||
39 | // tagBITMAPFILEHEADER - bitmap file header. |
||
40 | // -------------------------------------------- |
||
41 | |||
42 | #pragma pack(2) |
||
43 | |||
44 | typedef struct tagBITMAPFILEHEADER // bmfh |
||
45 | { |
||
46 | unsigned short bfType; // magic number "BM" |
||
47 | unsigned int bfSize; // file size |
||
48 | unsigned short bfReserved1; // reserved |
||
49 | unsigned short bfReserved2; // reserved |
||
50 | unsigned int bfOffBits; // offset to bitmap data |
||
51 | |||
52 | } BITMAPFILEHEADER, *PBITMAPFILEHEADER; |
||
53 | |||
54 | #pragma pack(4) |
||
55 | |||
56 | |||
57 | |||
58 | // -------------------------------------------- |
||
59 | // tagBITMAPCOREHEADER - bitmap core header. |
||
60 | // -------------------------------------------- |
||
61 | |||
62 | typedef struct tagBITMAPCOREHEADER // bmch |
||
63 | { |
||
64 | unsigned int bcSize; // size of the structure |
||
65 | unsigned short bcWidth; // image width |
||
66 | unsigned short bcHeight; // image height |
||
67 | unsigned short bcPlanes; // must be equal to 1 |
||
68 | unsigned short bcBitCount; // number of bits per pixel |
||
69 | |||
70 | } BITMAPCOREHEADER, *PBITMAPCOREHEADER; |
||
71 | |||
72 | |||
73 | |||
74 | // -------------------------------------------- |
||
75 | // tagRGBTRIPLE - 24 bits pixel |
||
76 | // -------------------------------------------- |
||
77 | |||
78 | typedef struct tagRGBTRIPLE // rgbt |
||
79 | { |
||
80 | unsigned char rgbtBlue; // blue |
||
81 | unsigned char rgbtGreen; // green |
||
82 | unsigned char rgbtRed; // red |
||
83 | |||
84 | } RGBTRIPLE, *PRGBTRIPLE; |
||
85 | |||
86 | |||
87 | |||
88 | // -------------------------------------------- |
||
89 | // tagRGBQUAD - 32 bits pixel |
||
90 | // -------------------------------------------- |
||
91 | |||
92 | typedef struct tagRGBQUAD // rgbt |
||
93 | { |
||
94 | unsigned char rgbBlue; // blue |
||
95 | unsigned char rgbGreen; // green |
||
96 | unsigned char rgbRed; // red |
||
97 | unsigned char rgbReserved; // reserved |
||
98 | |||
99 | } RGBQUAD, *PRGBQUAD; |
||
100 | |||
101 | |||
102 | |||
103 | // -------------------------------------------- |
||
104 | // tagBITMAPCOREINFO - bitmap core info. |
||
105 | // -------------------------------------------- |
||
106 | |||
107 | typedef struct tagBITMAPCOREINFO // bmci |
||
108 | { |
||
109 | BITMAPCOREHEADER bmciHeader; // size of the structure |
||
110 | RGBTRIPLE bcmiColors[1]; // color palette |
||
111 | |||
112 | } BITMAPCOREINFO, *PBITMAPCOREINFO; |
||
113 | |||
114 | |||
115 | // -------------------------------------------- |
||
116 | // BITMAPFILEHEADER - bitmap info header. |
||
117 | // -------------------------------------------- |
||
118 | |||
119 | typedef struct tagBITMAPINFOHEADER |
||
120 | { |
||
121 | unsigned int biSize; // size of the structure |
||
122 | int biWidth; // image width |
||
123 | int biHeight; // image height |
||
124 | unsigned short biPlanes; // must be equal to 1 |
||
125 | unsigned short biBitCount; // number of bits per pixel |
||
126 | unsigned int biCompression; // compression type |
||
127 | unsigned int biSizeImage; // size of data bitmap |
||
128 | int biXPelsPerMeter; // number of pixels per meter on the X axis |
||
129 | int biYPelsPerMeter; // number of pixels per meter on the Y axis |
||
130 | unsigned int biClrUsed; // number of colors used |
||
131 | unsigned int biClrImportant; // number of important colors |
||
132 | |||
133 | } BITMAPINFOHEADER, *PBITMAPINFOHEADER; |
||
134 | |||
135 | |||
136 | |||
137 | // prototype |
||
138 | int LoadFileBMP( const char *filename, unsigned char **pixels, int *width, int *height, bool flipvert ); |
||
139 | |||
140 | |||
141 | |||
142 | #endif // __BITMAP_H_8)) |