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