]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - plugins/image/bmp.h
transfer from internal tree r5311 branches/1.4-gpl
[xonotic/netradiant.git] / plugins / image / bmp.h
1 /*\r
2 Copyright (C) 1999-2007 id Software, Inc. and contributors.\r
3 For a list of contributors, see the accompanying CONTRIBUTORS file.\r
4 \r
5 This file is part of GtkRadiant.\r
6 \r
7 GtkRadiant is free software; you can redistribute it and/or modify\r
8 it under the terms of the GNU General Public License as published by\r
9 the Free Software Foundation; either version 2 of the License, or\r
10 (at your option) any later version.\r
11 \r
12 GtkRadiant is distributed in the hope that it will be useful,\r
13 but WITHOUT ANY WARRANTY; without even the implied warranty of\r
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
15 GNU General Public License for more details.\r
16 \r
17 You should have received a copy of the GNU General Public License\r
18 along with GtkRadiant; if not, write to the Free Software\r
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\r
20 */\r
21 \r
22 #ifndef _BMP_H\r
23 #define _BMP_H\r
24 \r
25 #define xBI_NONE  0\r
26 #define xBI_RGB   0\r
27 #define xBI_RLE4  2\r
28 #define xBI_RLE8  1\r
29 \r
30 #define BMP_SIGNATURE_WORD  0x4d42\r
31 \r
32 #pragma pack(1)\r
33 \r
34 \r
35 \r
36 typedef struct {\r
37     unsigned short    bfType;       // signature - 'BM'\r
38     unsigned long     bfSize;       // file size in bytes\r
39     unsigned short    bfReserved1;  // 0\r
40     unsigned short    bfReserved2;  // 0\r
41     unsigned long     bfOffBits;    // offset to bitmap\r
42 } bmphd_t;\r
43 \r
44 \r
45 \r
46 typedef struct {\r
47     unsigned long     biSize;       // size of this struct\r
48     long              biWidth;      // bmap width in pixels\r
49     long              biHeight;     // bmap height in pixels\r
50     unsigned short    biPlanes;     // num planes - always 1\r
51     unsigned short    biBitCount;   // bits perpixel\r
52     unsigned long     biCompression; // compression flag\r
53     unsigned long     biSizeImage;   // image size in bytes\r
54     long              biXPelsPerMeter; // horz resolution\r
55     long              biYPelsPerMeter; // vert resolution\r
56     unsigned long     biClrUsed;       // 0 -> color table size\r
57     unsigned long     biClrImportant;  // important color count\r
58 } binfo_t;\r
59 \r
60 \r
61 typedef struct {\r
62     unsigned char blue;\r
63     unsigned char green;\r
64     unsigned char red;\r
65     unsigned char reserved;\r
66 } drgb_t;\r
67 \r
68 \r
69 // quake expects its palette to be bgr\r
70 // this is totally backwards but what can you do\r
71 typedef struct {\r
72     unsigned char r;\r
73     unsigned char g;\r
74     unsigned char b;\r
75 } rgb_t;\r
76 \r
77 \r
78 typedef struct {\r
79     unsigned char b;\r
80     unsigned char g;\r
81     unsigned char r;\r
82 } bgr_t;\r
83 \r
84 \r
85 typedef struct {\r
86         int            bpp;        // bits per pixel\r
87     int            width;\r
88     int            height;\r
89     unsigned char *data;\r
90     rgb_t         *palette;\r
91 } bitmap_t;\r
92 \r
93 \r
94 void LoadBMP(char *filename, bitmap_t *bit);\r
95 void FreeBMP(bitmap_t *bitmap);\r
96 void WriteBMP(char *filename, bitmap_t *bit);\r
97 void NewBMP(int width, int height, int bpp, bitmap_t *bit);\r
98 \r
99 \r
100 \r
101 #endif\r