1 /*
2  * OpenClonk, http://www.openclonk.org
3  *
4  * Copyright (c) 1998-2000, Matthes Bender
5  * Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de/
6  * Copyright (c) 2009-2016, The OpenClonk Team and contributors
7  *
8  * Distributed under the terms of the ISC license; see accompanying file
9  * "COPYING" for details.
10  *
11  * "Clonk" is a registered trademark of Matthes Bender, used with permission.
12  * See accompanying file "TRADEMARK" for details.
13  *
14  * To redistribute this file separately, substitute the full license texts
15  * for the above references.
16  */
17 
18 /* A structure for handling 256-color bitmap files */
19 
20 #ifndef BITMAP256_H_INC
21 #define BITMAP256_H_INC
22 
23 #ifdef _WIN32
24 #include "platform/C4windowswrapper.h"
25 #else
26 #pragma pack(push,2)
27 typedef struct tagBITMAPFILEHEADER
28 {
29 	WORD  bfType;
30 	DWORD bfSize;
31 	WORD  bfReserved1;
32 	WORD  bfReserved2;
33 	DWORD bfOffBits;
34 } BITMAPFILEHEADER,*LPBITMAPFILEHEADER,*PBITMAPFILEHEADER;
35 #pragma pack(pop)
36 typedef struct tagBITMAPINFOHEADER
37 {
38 	DWORD biSize;
39 	int32_t biWidth;
40 	int32_t biHeight;
41 	WORD  biPlanes;
42 	WORD  biBitCount;
43 	DWORD biCompression;
44 	DWORD biSizeImage;
45 	int32_t biXPelsPerMeter;
46 	int32_t biYPelsPerMeter;
47 	DWORD biClrUsed;
48 	DWORD biClrImportant;
49 } BITMAPINFOHEADER,*LPBITMAPINFOHEADER,*PBITMAPINFOHEADER;
50 typedef struct tagRGBQUAD
51 {
52 	BYTE  rgbBlue;
53 	BYTE  rgbGreen;
54 	BYTE  rgbRed;
55 	BYTE  rgbReserved;
56 } RGBQUAD,*LPRGBQUAD;
57 #endif
58 
59 #pragma pack( push, def_pack , 1)
60 
61 class C4BMPInfo
62 {
63 public:
64 	void Default();
65 public:
66 	BITMAPFILEHEADER Head = BITMAPFILEHEADER();
67 	BITMAPINFOHEADER Info = BITMAPINFOHEADER();
68 	void Set(int iWdt, int iHgt, int iBitDepth);
69 
70 	int FileBitsOffset();
71 };
72 
73 class C4BMP256Info : public C4BMPInfo
74 {
75 public:
76 	RGBQUAD Colors[256] = {};
77 public:
78 	void Default();
79 	void Set(int iWdt, int iHgt, CStdPalette *);
80 	bool Valid();
81 
82 	int FileBitsOffset();
83 };
84 
85 #pragma pack( pop, def_pack )
86 
87 #endif // BITMAP256_H_INC
88