comparison include/SDL_pixels.h @ 1662:782fd950bd46 SDL-1.3

Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API. WARNING: None of the video drivers have been updated for the new API yet! The API is still under design and very fluid. The code is now run through a consistent indent format: indent -i4 -nut -nsc -br -ce The headers are being converted to automatically generate doxygen documentation.
author Sam Lantinga <slouken@libsdl.org>
date Sun, 28 May 2006 13:04:16 +0000
parents
children 4da1ee79c9af
comparison
equal deleted inserted replaced
1661:281d3f4870e5 1662:782fd950bd46
1 /*
2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2006 Sam Lantinga
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19 Sam Lantinga
20 slouken@libsdl.org
21 */
22
23 /**
24 * \file SDL_pixels.h
25 *
26 * Header for the enumerated pixel format definitions
27 */
28
29 #ifndef _SDL_pixels_h
30 #define _SDL_pixels_h
31
32 #include "begin_code.h"
33 /* Set up for C function definitions, even when using C++ */
34 #ifdef __cplusplus
35 /* *INDENT-OFF* */
36 extern "C" {
37 /* *INDENT-ON* */
38 #endif
39
40 enum
41 { /* Pixel type */
42 SDL_PixelType_Unknown,
43 SDL_PixelType_Index1,
44 SDL_PixelType_Index4,
45 SDL_PixelType_Index8,
46 SDL_PixelType_Packed8,
47 SDL_PixelType_Packed16,
48 SDL_PixelType_Packed32,
49 SDL_PixelType_ArrayU8,
50 SDL_PixelType_ArrayU16,
51 SDL_PixelType_ArrayU32,
52 SDL_PixelType_ArrayF16,
53 SDL_PixelType_ArrayF32,
54 };
55
56 enum
57 { /* bitmap pixel order, high bit -> low bit */
58 SDL_BitmapOrder_None,
59 SDL_BitmapOrder_4321,
60 SDL_BitmapOrder_1234,
61 };
62 enum
63 { /* packed component order, high bit -> low bit */
64 SDL_PackedOrder_None,
65 SDL_PackedOrder_XRGB,
66 SDL_PackedOrder_RGBX,
67 SDL_PackedOrder_ARGB,
68 SDL_PackedOrder_RGBA,
69 SDL_PackedOrder_XBGR,
70 SDL_PackedOrder_BGRX,
71 SDL_PackedOrder_ABGR,
72 SDL_PackedOrder_BGRA,
73 };
74 enum
75 { /* array component order, low byte -> high byte */
76 SDL_ArrayOrder_None,
77 SDL_ArrayOrder_RGB,
78 SDL_ArrayOrder_RGBA,
79 SDL_ArrayOrder_ARGB,
80 SDL_ArrayOrder_BGR,
81 SDL_ArrayOrder_BGRA,
82 SDL_ArrayOrder_ABGR,
83 };
84
85 enum
86 { /* Packed component layout */
87 SDL_PackedLayout_None,
88 SDL_PackedLayout_332,
89 SDL_PackedLayout_4444,
90 SDL_PackedLayout_1555,
91 SDL_PackedLayout_5551,
92 SDL_PackedLayout_565,
93 SDL_PackedLayout_8888,
94 SDL_PackedLayout_2101010,
95 SDL_PackedLayout_1010102,
96 };
97
98 #define SDL_DEFINE_PIXELFORMAT(type, order, layout, bits, bytes) \
99 ((1 << 31) | ((type) << 24) | ((order) << 20) | ((layout) << 16) | \
100 ((bits) << 8) | ((bytes) << 0))
101
102 #define SDL_PIXELTYPE(X) (((X) >> 24) & 0x0F)
103 #define SDL_PIXELORDER(X) (((X) >> 20) & 0x0F)
104 #define SDL_PIXELLAYOUT(X) (((X) >> 16) & 0x0F)
105 #define SDL_BITSPERPIXEL(X) (((X) >> 8) & 0xFF)
106 #define SDL_BYTESPERPIXEL(X) (((X) >> 0) & 0xFF)
107
108 enum
109 {
110 SDL_PixelFormat_Unknown,
111 SDL_PixelFormat_Index1LSB =
112 SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Index1, SDL_BitmapOrder_1234, 0,
113 1, 0),
114 SDL_PixelFormat_Index1MSB =
115 SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Index1, SDL_BitmapOrder_4321, 0,
116 1, 0),
117 SDL_PixelFormat_Index4LSB =
118 SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Index4, SDL_BitmapOrder_1234, 0,
119 2, 0),
120 SDL_PixelFormat_Index4MSB =
121 SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Index4, SDL_BitmapOrder_4321, 0,
122 2, 0),
123 SDL_PixelFormat_Index8 =
124 SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Index8, 0, 0, 8, 1),
125 SDL_PixelFormat_RGB332 =
126 SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Packed8, SDL_PackedOrder_XRGB,
127 SDL_PackedLayout_332, 8, 1),
128 SDL_PixelFormat_RGB444 =
129 SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Packed16, SDL_PackedOrder_XRGB,
130 SDL_PackedLayout_4444, 12, 2),
131 SDL_PixelFormat_RGB555 =
132 SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Packed16, SDL_PackedOrder_XRGB,
133 SDL_PackedLayout_1555, 15, 2),
134 SDL_PixelFormat_ARGB4444 =
135 SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Packed16, SDL_PackedOrder_ARGB,
136 SDL_PackedLayout_4444, 16, 2),
137 SDL_PixelFormat_ARGB1555 =
138 SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Packed16, SDL_PackedOrder_ARGB,
139 SDL_PackedLayout_1555, 16, 2),
140 SDL_PixelFormat_RGB565 =
141 SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Packed16, SDL_PackedOrder_XRGB,
142 SDL_PackedLayout_565, 16, 2),
143 SDL_PixelFormat_RGB24 =
144 SDL_DEFINE_PIXELFORMAT (SDL_PixelType_ArrayU8, SDL_ArrayOrder_RGB, 0,
145 24, 3),
146 SDL_PixelFormat_BGR24 =
147 SDL_DEFINE_PIXELFORMAT (SDL_PixelType_ArrayU8, SDL_ArrayOrder_BGR, 0,
148 24, 3),
149 SDL_PixelFormat_RGB888 =
150 SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Packed32, SDL_PackedOrder_XRGB,
151 SDL_PackedLayout_8888, 24, 4),
152 SDL_PixelFormat_BGR888 =
153 SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Packed32, SDL_PackedOrder_XBGR,
154 SDL_PackedLayout_8888, 24, 4),
155 SDL_PixelFormat_ARGB8888 =
156 SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Packed32, SDL_PackedOrder_ARGB,
157 SDL_PackedLayout_8888, 32, 4),
158 SDL_PixelFormat_RGBA8888 =
159 SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Packed32, SDL_PackedOrder_RGBA,
160 SDL_PackedLayout_8888, 32, 4),
161 SDL_PixelFormat_ABGR8888 =
162 SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Packed32, SDL_PackedOrder_ABGR,
163 SDL_PackedLayout_8888, 32, 4),
164 SDL_PixelFormat_BGRA8888 =
165 SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Packed32, SDL_PackedOrder_BGRA,
166 SDL_PackedLayout_8888, 32, 4),
167 SDL_PixelFormat_ARGB2101010 =
168 SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Packed32, SDL_PackedOrder_ARGB,
169 SDL_PackedLayout_2101010, 32, 4),
170 };
171
172 typedef struct SDL_Color
173 {
174 Uint8 r;
175 Uint8 g;
176 Uint8 b;
177 Uint8 unused;
178 } SDL_Color;
179 #define SDL_Colour SDL_Color
180
181 typedef struct SDL_Palette
182 {
183 int ncolors;
184 SDL_Color *colors;
185 } SDL_Palette;
186
187 /* Everything in the pixel format structure is read-only */
188 typedef struct SDL_PixelFormat
189 {
190 SDL_Palette *palette;
191 Uint8 BitsPerPixel;
192 Uint8 BytesPerPixel;
193 Uint8 Rloss;
194 Uint8 Gloss;
195 Uint8 Bloss;
196 Uint8 Aloss;
197 Uint8 Rshift;
198 Uint8 Gshift;
199 Uint8 Bshift;
200 Uint8 Ashift;
201 Uint32 Rmask;
202 Uint32 Gmask;
203 Uint32 Bmask;
204 Uint32 Amask;
205
206 /* RGB color key information */
207 Uint32 colorkey;
208 /* Alpha value information (per-surface alpha) */
209 Uint8 alpha;
210 } SDL_PixelFormat;
211
212 /*
213 * Convert one of the enumerated formats above to a bpp and RGBA masks.
214 * Returns SDL_TRUE, or SDL_FALSE if the conversion wasn't possible.
215 */
216 extern DECLSPEC SDL_bool SDL_PixelFormatEnumToMasks (Uint32 format, int *bpp,
217 Uint32 * Rmask,
218 Uint32 * Gmask,
219 Uint32 * Bmask,
220 Uint32 * Amask);
221
222 /*
223 * Convert a bpp and RGBA masks to one of the enumerated formats above.
224 * Returns SDL_PixelFormat_Unknown if the conversion wasn't possible.
225 */
226 extern DECLSPEC Uint32 SDL_MasksToPixelFormatEnum (int bpp, Uint32 Rmask,
227 Uint32 Gmask, Uint32 Bmask,
228 Uint32 Amask);
229
230 /* Ends C function definitions when using C++ */
231 #ifdef __cplusplus
232 /* *INDENT-OFF* */
233 }
234 /* *INDENT-ON* */
235 #endif
236 #include "close_code.h"
237
238 #endif /* _SDL_pixels_h */
239
240 /* vi: set ts=4 sw=4 expandtab: */