diff options
author | 3gg <3gg@shellblade.net> | 2024-05-04 16:51:29 -0700 |
---|---|---|
committer | 3gg <3gg@shellblade.net> | 2024-05-04 16:51:29 -0700 |
commit | 8222bfe56d4dabe8d92fc4b25ea1b0163b16f3e1 (patch) | |
tree | 763389e42276035ac134d94eb1dc32293b88d807 /src/contrib/SDL-2.30.2/include/SDL_pixels.h |
Initial commit.
Diffstat (limited to 'src/contrib/SDL-2.30.2/include/SDL_pixels.h')
-rw-r--r-- | src/contrib/SDL-2.30.2/include/SDL_pixels.h | 662 |
1 files changed, 662 insertions, 0 deletions
diff --git a/src/contrib/SDL-2.30.2/include/SDL_pixels.h b/src/contrib/SDL-2.30.2/include/SDL_pixels.h new file mode 100644 index 0000000..44757cd --- /dev/null +++ b/src/contrib/SDL-2.30.2/include/SDL_pixels.h | |||
@@ -0,0 +1,662 @@ | |||
1 | /* | ||
2 | Simple DirectMedia Layer | ||
3 | Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org> | ||
4 | |||
5 | This software is provided 'as-is', without any express or implied | ||
6 | warranty. In no event will the authors be held liable for any damages | ||
7 | arising from the use of this software. | ||
8 | |||
9 | Permission is granted to anyone to use this software for any purpose, | ||
10 | including commercial applications, and to alter it and redistribute it | ||
11 | freely, subject to the following restrictions: | ||
12 | |||
13 | 1. The origin of this software must not be misrepresented; you must not | ||
14 | claim that you wrote the original software. If you use this software | ||
15 | in a product, an acknowledgment in the product documentation would be | ||
16 | appreciated but is not required. | ||
17 | 2. Altered source versions must be plainly marked as such, and must not be | ||
18 | misrepresented as being the original software. | ||
19 | 3. This notice may not be removed or altered from any source distribution. | ||
20 | */ | ||
21 | |||
22 | /** | ||
23 | * \file SDL_pixels.h | ||
24 | * | ||
25 | * Header for the enumerated pixel format definitions. | ||
26 | */ | ||
27 | |||
28 | #ifndef SDL_pixels_h_ | ||
29 | #define SDL_pixels_h_ | ||
30 | |||
31 | #include "SDL_stdinc.h" | ||
32 | #include "SDL_endian.h" | ||
33 | |||
34 | #include "begin_code.h" | ||
35 | /* Set up for C function definitions, even when using C++ */ | ||
36 | #ifdef __cplusplus | ||
37 | extern "C" { | ||
38 | #endif | ||
39 | |||
40 | /** | ||
41 | * \name Transparency definitions | ||
42 | * | ||
43 | * These define alpha as the opacity of a surface. | ||
44 | */ | ||
45 | /* @{ */ | ||
46 | #define SDL_ALPHA_OPAQUE 255 | ||
47 | #define SDL_ALPHA_TRANSPARENT 0 | ||
48 | /* @} */ | ||
49 | |||
50 | /** Pixel type. */ | ||
51 | typedef enum | ||
52 | { | ||
53 | SDL_PIXELTYPE_UNKNOWN, | ||
54 | SDL_PIXELTYPE_INDEX1, | ||
55 | SDL_PIXELTYPE_INDEX4, | ||
56 | SDL_PIXELTYPE_INDEX8, | ||
57 | SDL_PIXELTYPE_PACKED8, | ||
58 | SDL_PIXELTYPE_PACKED16, | ||
59 | SDL_PIXELTYPE_PACKED32, | ||
60 | SDL_PIXELTYPE_ARRAYU8, | ||
61 | SDL_PIXELTYPE_ARRAYU16, | ||
62 | SDL_PIXELTYPE_ARRAYU32, | ||
63 | SDL_PIXELTYPE_ARRAYF16, | ||
64 | SDL_PIXELTYPE_ARRAYF32, | ||
65 | |||
66 | /* This must be at the end of the list to avoid breaking the existing ABI */ | ||
67 | SDL_PIXELTYPE_INDEX2 | ||
68 | } SDL_PixelType; | ||
69 | |||
70 | /** Bitmap pixel order, high bit -> low bit. */ | ||
71 | typedef enum | ||
72 | { | ||
73 | SDL_BITMAPORDER_NONE, | ||
74 | SDL_BITMAPORDER_4321, | ||
75 | SDL_BITMAPORDER_1234 | ||
76 | } SDL_BitmapOrder; | ||
77 | |||
78 | /** Packed component order, high bit -> low bit. */ | ||
79 | typedef enum | ||
80 | { | ||
81 | SDL_PACKEDORDER_NONE, | ||
82 | SDL_PACKEDORDER_XRGB, | ||
83 | SDL_PACKEDORDER_RGBX, | ||
84 | SDL_PACKEDORDER_ARGB, | ||
85 | SDL_PACKEDORDER_RGBA, | ||
86 | SDL_PACKEDORDER_XBGR, | ||
87 | SDL_PACKEDORDER_BGRX, | ||
88 | SDL_PACKEDORDER_ABGR, | ||
89 | SDL_PACKEDORDER_BGRA | ||
90 | } SDL_PackedOrder; | ||
91 | |||
92 | /** Array component order, low byte -> high byte. */ | ||
93 | /* !!! FIXME: in 2.1, make these not overlap differently with | ||
94 | !!! FIXME: SDL_PACKEDORDER_*, so we can simplify SDL_ISPIXELFORMAT_ALPHA */ | ||
95 | typedef enum | ||
96 | { | ||
97 | SDL_ARRAYORDER_NONE, | ||
98 | SDL_ARRAYORDER_RGB, | ||
99 | SDL_ARRAYORDER_RGBA, | ||
100 | SDL_ARRAYORDER_ARGB, | ||
101 | SDL_ARRAYORDER_BGR, | ||
102 | SDL_ARRAYORDER_BGRA, | ||
103 | SDL_ARRAYORDER_ABGR | ||
104 | } SDL_ArrayOrder; | ||
105 | |||
106 | /** Packed component layout. */ | ||
107 | typedef enum | ||
108 | { | ||
109 | SDL_PACKEDLAYOUT_NONE, | ||
110 | SDL_PACKEDLAYOUT_332, | ||
111 | SDL_PACKEDLAYOUT_4444, | ||
112 | SDL_PACKEDLAYOUT_1555, | ||
113 | SDL_PACKEDLAYOUT_5551, | ||
114 | SDL_PACKEDLAYOUT_565, | ||
115 | SDL_PACKEDLAYOUT_8888, | ||
116 | SDL_PACKEDLAYOUT_2101010, | ||
117 | SDL_PACKEDLAYOUT_1010102 | ||
118 | } SDL_PackedLayout; | ||
119 | |||
120 | #define SDL_DEFINE_PIXELFOURCC(A, B, C, D) SDL_FOURCC(A, B, C, D) | ||
121 | |||
122 | #define SDL_DEFINE_PIXELFORMAT(type, order, layout, bits, bytes) \ | ||
123 | ((1 << 28) | ((type) << 24) | ((order) << 20) | ((layout) << 16) | \ | ||
124 | ((bits) << 8) | ((bytes) << 0)) | ||
125 | |||
126 | #define SDL_PIXELFLAG(X) (((X) >> 28) & 0x0F) | ||
127 | #define SDL_PIXELTYPE(X) (((X) >> 24) & 0x0F) | ||
128 | #define SDL_PIXELORDER(X) (((X) >> 20) & 0x0F) | ||
129 | #define SDL_PIXELLAYOUT(X) (((X) >> 16) & 0x0F) | ||
130 | #define SDL_BITSPERPIXEL(X) (((X) >> 8) & 0xFF) | ||
131 | #define SDL_BYTESPERPIXEL(X) \ | ||
132 | (SDL_ISPIXELFORMAT_FOURCC(X) ? \ | ||
133 | ((((X) == SDL_PIXELFORMAT_YUY2) || \ | ||
134 | ((X) == SDL_PIXELFORMAT_UYVY) || \ | ||
135 | ((X) == SDL_PIXELFORMAT_YVYU)) ? 2 : 1) : (((X) >> 0) & 0xFF)) | ||
136 | |||
137 | #define SDL_ISPIXELFORMAT_INDEXED(format) \ | ||
138 | (!SDL_ISPIXELFORMAT_FOURCC(format) && \ | ||
139 | ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX1) || \ | ||
140 | (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX2) || \ | ||
141 | (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX4) || \ | ||
142 | (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX8))) | ||
143 | |||
144 | #define SDL_ISPIXELFORMAT_PACKED(format) \ | ||
145 | (!SDL_ISPIXELFORMAT_FOURCC(format) && \ | ||
146 | ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_PACKED8) || \ | ||
147 | (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_PACKED16) || \ | ||
148 | (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_PACKED32))) | ||
149 | |||
150 | #define SDL_ISPIXELFORMAT_ARRAY(format) \ | ||
151 | (!SDL_ISPIXELFORMAT_FOURCC(format) && \ | ||
152 | ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYU8) || \ | ||
153 | (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYU16) || \ | ||
154 | (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYU32) || \ | ||
155 | (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYF16) || \ | ||
156 | (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYF32))) | ||
157 | |||
158 | #define SDL_ISPIXELFORMAT_ALPHA(format) \ | ||
159 | ((SDL_ISPIXELFORMAT_PACKED(format) && \ | ||
160 | ((SDL_PIXELORDER(format) == SDL_PACKEDORDER_ARGB) || \ | ||
161 | (SDL_PIXELORDER(format) == SDL_PACKEDORDER_RGBA) || \ | ||
162 | (SDL_PIXELORDER(format) == SDL_PACKEDORDER_ABGR) || \ | ||
163 | (SDL_PIXELORDER(format) == SDL_PACKEDORDER_BGRA))) || \ | ||
164 | (SDL_ISPIXELFORMAT_ARRAY(format) && \ | ||
165 | ((SDL_PIXELORDER(format) == SDL_ARRAYORDER_ARGB) || \ | ||
166 | (SDL_PIXELORDER(format) == SDL_ARRAYORDER_RGBA) || \ | ||
167 | (SDL_PIXELORDER(format) == SDL_ARRAYORDER_ABGR) || \ | ||
168 | (SDL_PIXELORDER(format) == SDL_ARRAYORDER_BGRA)))) | ||
169 | |||
170 | /* The flag is set to 1 because 0x1? is not in the printable ASCII range */ | ||
171 | #define SDL_ISPIXELFORMAT_FOURCC(format) \ | ||
172 | ((format) && (SDL_PIXELFLAG(format) != 1)) | ||
173 | |||
174 | /* Note: If you modify this list, update SDL_GetPixelFormatName() */ | ||
175 | typedef enum | ||
176 | { | ||
177 | SDL_PIXELFORMAT_UNKNOWN, | ||
178 | SDL_PIXELFORMAT_INDEX1LSB = | ||
179 | SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_4321, 0, | ||
180 | 1, 0), | ||
181 | SDL_PIXELFORMAT_INDEX1MSB = | ||
182 | SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_1234, 0, | ||
183 | 1, 0), | ||
184 | SDL_PIXELFORMAT_INDEX2LSB = | ||
185 | SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX2, SDL_BITMAPORDER_4321, 0, | ||
186 | 2, 0), | ||
187 | SDL_PIXELFORMAT_INDEX2MSB = | ||
188 | SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX2, SDL_BITMAPORDER_1234, 0, | ||
189 | 2, 0), | ||
190 | SDL_PIXELFORMAT_INDEX4LSB = | ||
191 | SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_4321, 0, | ||
192 | 4, 0), | ||
193 | SDL_PIXELFORMAT_INDEX4MSB = | ||
194 | SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_1234, 0, | ||
195 | 4, 0), | ||
196 | SDL_PIXELFORMAT_INDEX8 = | ||
197 | SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX8, 0, 0, 8, 1), | ||
198 | SDL_PIXELFORMAT_RGB332 = | ||
199 | SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED8, SDL_PACKEDORDER_XRGB, | ||
200 | SDL_PACKEDLAYOUT_332, 8, 1), | ||
201 | SDL_PIXELFORMAT_XRGB4444 = | ||
202 | SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB, | ||
203 | SDL_PACKEDLAYOUT_4444, 12, 2), | ||
204 | SDL_PIXELFORMAT_RGB444 = SDL_PIXELFORMAT_XRGB4444, | ||
205 | SDL_PIXELFORMAT_XBGR4444 = | ||
206 | SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR, | ||
207 | SDL_PACKEDLAYOUT_4444, 12, 2), | ||
208 | SDL_PIXELFORMAT_BGR444 = SDL_PIXELFORMAT_XBGR4444, | ||
209 | SDL_PIXELFORMAT_XRGB1555 = | ||
210 | SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB, | ||
211 | SDL_PACKEDLAYOUT_1555, 15, 2), | ||
212 | SDL_PIXELFORMAT_RGB555 = SDL_PIXELFORMAT_XRGB1555, | ||
213 | SDL_PIXELFORMAT_XBGR1555 = | ||
214 | SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR, | ||
215 | SDL_PACKEDLAYOUT_1555, 15, 2), | ||
216 | SDL_PIXELFORMAT_BGR555 = SDL_PIXELFORMAT_XBGR1555, | ||
217 | SDL_PIXELFORMAT_ARGB4444 = | ||
218 | SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ARGB, | ||
219 | SDL_PACKEDLAYOUT_4444, 16, 2), | ||
220 | SDL_PIXELFORMAT_RGBA4444 = | ||
221 | SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_RGBA, | ||
222 | SDL_PACKEDLAYOUT_4444, 16, 2), | ||
223 | SDL_PIXELFORMAT_ABGR4444 = | ||
224 | SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ABGR, | ||
225 | SDL_PACKEDLAYOUT_4444, 16, 2), | ||
226 | SDL_PIXELFORMAT_BGRA4444 = | ||
227 | SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_BGRA, | ||
228 | SDL_PACKEDLAYOUT_4444, 16, 2), | ||
229 | SDL_PIXELFORMAT_ARGB1555 = | ||
230 | SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ARGB, | ||
231 | SDL_PACKEDLAYOUT_1555, 16, 2), | ||
232 | SDL_PIXELFORMAT_RGBA5551 = | ||
233 | SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_RGBA, | ||
234 | SDL_PACKEDLAYOUT_5551, 16, 2), | ||
235 | SDL_PIXELFORMAT_ABGR1555 = | ||
236 | SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ABGR, | ||
237 | SDL_PACKEDLAYOUT_1555, 16, 2), | ||
238 | SDL_PIXELFORMAT_BGRA5551 = | ||
239 | SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_BGRA, | ||
240 | SDL_PACKEDLAYOUT_5551, 16, 2), | ||
241 | SDL_PIXELFORMAT_RGB565 = | ||
242 | SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB, | ||
243 | SDL_PACKEDLAYOUT_565, 16, 2), | ||
244 | SDL_PIXELFORMAT_BGR565 = | ||
245 | SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR, | ||
246 | SDL_PACKEDLAYOUT_565, 16, 2), | ||
247 | SDL_PIXELFORMAT_RGB24 = | ||
248 | SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_RGB, 0, | ||
249 | 24, 3), | ||
250 | SDL_PIXELFORMAT_BGR24 = | ||
251 | SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_BGR, 0, | ||
252 | 24, 3), | ||
253 | SDL_PIXELFORMAT_XRGB8888 = | ||
254 | SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XRGB, | ||
255 | SDL_PACKEDLAYOUT_8888, 24, 4), | ||
256 | SDL_PIXELFORMAT_RGB888 = SDL_PIXELFORMAT_XRGB8888, | ||
257 | SDL_PIXELFORMAT_RGBX8888 = | ||
258 | SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBX, | ||
259 | SDL_PACKEDLAYOUT_8888, 24, 4), | ||
260 | SDL_PIXELFORMAT_XBGR8888 = | ||
261 | SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XBGR, | ||
262 | SDL_PACKEDLAYOUT_8888, 24, 4), | ||
263 | SDL_PIXELFORMAT_BGR888 = SDL_PIXELFORMAT_XBGR8888, | ||
264 | SDL_PIXELFORMAT_BGRX8888 = | ||
265 | SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_BGRX, | ||
266 | SDL_PACKEDLAYOUT_8888, 24, 4), | ||
267 | SDL_PIXELFORMAT_ARGB8888 = | ||
268 | SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ARGB, | ||
269 | SDL_PACKEDLAYOUT_8888, 32, 4), | ||
270 | SDL_PIXELFORMAT_RGBA8888 = | ||
271 | SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBA, | ||
272 | SDL_PACKEDLAYOUT_8888, 32, 4), | ||
273 | SDL_PIXELFORMAT_ABGR8888 = | ||
274 | SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ABGR, | ||
275 | SDL_PACKEDLAYOUT_8888, 32, 4), | ||
276 | SDL_PIXELFORMAT_BGRA8888 = | ||
277 | SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_BGRA, | ||
278 | SDL_PACKEDLAYOUT_8888, 32, 4), | ||
279 | SDL_PIXELFORMAT_ARGB2101010 = | ||
280 | SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ARGB, | ||
281 | SDL_PACKEDLAYOUT_2101010, 32, 4), | ||
282 | |||
283 | /* Aliases for RGBA byte arrays of color data, for the current platform */ | ||
284 | #if SDL_BYTEORDER == SDL_BIG_ENDIAN | ||
285 | SDL_PIXELFORMAT_RGBA32 = SDL_PIXELFORMAT_RGBA8888, | ||
286 | SDL_PIXELFORMAT_ARGB32 = SDL_PIXELFORMAT_ARGB8888, | ||
287 | SDL_PIXELFORMAT_BGRA32 = SDL_PIXELFORMAT_BGRA8888, | ||
288 | SDL_PIXELFORMAT_ABGR32 = SDL_PIXELFORMAT_ABGR8888, | ||
289 | SDL_PIXELFORMAT_RGBX32 = SDL_PIXELFORMAT_RGBX8888, | ||
290 | SDL_PIXELFORMAT_XRGB32 = SDL_PIXELFORMAT_XRGB8888, | ||
291 | SDL_PIXELFORMAT_BGRX32 = SDL_PIXELFORMAT_BGRX8888, | ||
292 | SDL_PIXELFORMAT_XBGR32 = SDL_PIXELFORMAT_XBGR8888, | ||
293 | #else | ||
294 | SDL_PIXELFORMAT_RGBA32 = SDL_PIXELFORMAT_ABGR8888, | ||
295 | SDL_PIXELFORMAT_ARGB32 = SDL_PIXELFORMAT_BGRA8888, | ||
296 | SDL_PIXELFORMAT_BGRA32 = SDL_PIXELFORMAT_ARGB8888, | ||
297 | SDL_PIXELFORMAT_ABGR32 = SDL_PIXELFORMAT_RGBA8888, | ||
298 | SDL_PIXELFORMAT_RGBX32 = SDL_PIXELFORMAT_XBGR8888, | ||
299 | SDL_PIXELFORMAT_XRGB32 = SDL_PIXELFORMAT_BGRX8888, | ||
300 | SDL_PIXELFORMAT_BGRX32 = SDL_PIXELFORMAT_XRGB8888, | ||
301 | SDL_PIXELFORMAT_XBGR32 = SDL_PIXELFORMAT_RGBX8888, | ||
302 | #endif | ||
303 | |||
304 | SDL_PIXELFORMAT_YV12 = /**< Planar mode: Y + V + U (3 planes) */ | ||
305 | SDL_DEFINE_PIXELFOURCC('Y', 'V', '1', '2'), | ||
306 | SDL_PIXELFORMAT_IYUV = /**< Planar mode: Y + U + V (3 planes) */ | ||
307 | SDL_DEFINE_PIXELFOURCC('I', 'Y', 'U', 'V'), | ||
308 | SDL_PIXELFORMAT_YUY2 = /**< Packed mode: Y0+U0+Y1+V0 (1 plane) */ | ||
309 | SDL_DEFINE_PIXELFOURCC('Y', 'U', 'Y', '2'), | ||
310 | SDL_PIXELFORMAT_UYVY = /**< Packed mode: U0+Y0+V0+Y1 (1 plane) */ | ||
311 | SDL_DEFINE_PIXELFOURCC('U', 'Y', 'V', 'Y'), | ||
312 | SDL_PIXELFORMAT_YVYU = /**< Packed mode: Y0+V0+Y1+U0 (1 plane) */ | ||
313 | SDL_DEFINE_PIXELFOURCC('Y', 'V', 'Y', 'U'), | ||
314 | SDL_PIXELFORMAT_NV12 = /**< Planar mode: Y + U/V interleaved (2 planes) */ | ||
315 | SDL_DEFINE_PIXELFOURCC('N', 'V', '1', '2'), | ||
316 | SDL_PIXELFORMAT_NV21 = /**< Planar mode: Y + V/U interleaved (2 planes) */ | ||
317 | SDL_DEFINE_PIXELFOURCC('N', 'V', '2', '1'), | ||
318 | SDL_PIXELFORMAT_EXTERNAL_OES = /**< Android video texture format */ | ||
319 | SDL_DEFINE_PIXELFOURCC('O', 'E', 'S', ' ') | ||
320 | } SDL_PixelFormatEnum; | ||
321 | |||
322 | /** | ||
323 | * The bits of this structure can be directly reinterpreted as an integer-packed | ||
324 | * color which uses the SDL_PIXELFORMAT_RGBA32 format (SDL_PIXELFORMAT_ABGR8888 | ||
325 | * on little-endian systems and SDL_PIXELFORMAT_RGBA8888 on big-endian systems). | ||
326 | */ | ||
327 | typedef struct SDL_Color | ||
328 | { | ||
329 | Uint8 r; | ||
330 | Uint8 g; | ||
331 | Uint8 b; | ||
332 | Uint8 a; | ||
333 | } SDL_Color; | ||
334 | #define SDL_Colour SDL_Color | ||
335 | |||
336 | typedef struct SDL_Palette | ||
337 | { | ||
338 | int ncolors; | ||
339 | SDL_Color *colors; | ||
340 | Uint32 version; | ||
341 | int refcount; | ||
342 | } SDL_Palette; | ||
343 | |||
344 | /** | ||
345 | * \note Everything in the pixel format structure is read-only. | ||
346 | */ | ||
347 | typedef struct SDL_PixelFormat | ||
348 | { | ||
349 | Uint32 format; | ||
350 | SDL_Palette *palette; | ||
351 | Uint8 BitsPerPixel; | ||
352 | Uint8 BytesPerPixel; | ||
353 | Uint8 padding[2]; | ||
354 | Uint32 Rmask; | ||
355 | Uint32 Gmask; | ||
356 | Uint32 Bmask; | ||
357 | Uint32 Amask; | ||
358 | Uint8 Rloss; | ||
359 | Uint8 Gloss; | ||
360 | Uint8 Bloss; | ||
361 | Uint8 Aloss; | ||
362 | Uint8 Rshift; | ||
363 | Uint8 Gshift; | ||
364 | Uint8 Bshift; | ||
365 | Uint8 Ashift; | ||
366 | int refcount; | ||
367 | struct SDL_PixelFormat *next; | ||
368 | } SDL_PixelFormat; | ||
369 | |||
370 | /** | ||
371 | * Get the human readable name of a pixel format. | ||
372 | * | ||
373 | * \param format the pixel format to query | ||
374 | * \returns the human readable name of the specified pixel format or | ||
375 | * `SDL_PIXELFORMAT_UNKNOWN` if the format isn't recognized. | ||
376 | * | ||
377 | * \since This function is available since SDL 2.0.0. | ||
378 | */ | ||
379 | extern DECLSPEC const char* SDLCALL SDL_GetPixelFormatName(Uint32 format); | ||
380 | |||
381 | /** | ||
382 | * Convert one of the enumerated pixel formats to a bpp value and RGBA masks. | ||
383 | * | ||
384 | * \param format one of the SDL_PixelFormatEnum values | ||
385 | * \param bpp a bits per pixel value; usually 15, 16, or 32 | ||
386 | * \param Rmask a pointer filled in with the red mask for the format | ||
387 | * \param Gmask a pointer filled in with the green mask for the format | ||
388 | * \param Bmask a pointer filled in with the blue mask for the format | ||
389 | * \param Amask a pointer filled in with the alpha mask for the format | ||
390 | * \returns SDL_TRUE on success or SDL_FALSE if the conversion wasn't | ||
391 | * possible; call SDL_GetError() for more information. | ||
392 | * | ||
393 | * \since This function is available since SDL 2.0.0. | ||
394 | * | ||
395 | * \sa SDL_MasksToPixelFormatEnum | ||
396 | */ | ||
397 | extern DECLSPEC SDL_bool SDLCALL SDL_PixelFormatEnumToMasks(Uint32 format, | ||
398 | int *bpp, | ||
399 | Uint32 * Rmask, | ||
400 | Uint32 * Gmask, | ||
401 | Uint32 * Bmask, | ||
402 | Uint32 * Amask); | ||
403 | |||
404 | /** | ||
405 | * Convert a bpp value and RGBA masks to an enumerated pixel format. | ||
406 | * | ||
407 | * This will return `SDL_PIXELFORMAT_UNKNOWN` if the conversion wasn't | ||
408 | * possible. | ||
409 | * | ||
410 | * \param bpp a bits per pixel value; usually 15, 16, or 32 | ||
411 | * \param Rmask the red mask for the format | ||
412 | * \param Gmask the green mask for the format | ||
413 | * \param Bmask the blue mask for the format | ||
414 | * \param Amask the alpha mask for the format | ||
415 | * \returns one of the SDL_PixelFormatEnum values | ||
416 | * | ||
417 | * \since This function is available since SDL 2.0.0. | ||
418 | * | ||
419 | * \sa SDL_PixelFormatEnumToMasks | ||
420 | */ | ||
421 | extern DECLSPEC Uint32 SDLCALL SDL_MasksToPixelFormatEnum(int bpp, | ||
422 | Uint32 Rmask, | ||
423 | Uint32 Gmask, | ||
424 | Uint32 Bmask, | ||
425 | Uint32 Amask); | ||
426 | |||
427 | /** | ||
428 | * Create an SDL_PixelFormat structure corresponding to a pixel format. | ||
429 | * | ||
430 | * Returned structure may come from a shared global cache (i.e. not newly | ||
431 | * allocated), and hence should not be modified, especially the palette. Weird | ||
432 | * errors such as `Blit combination not supported` may occur. | ||
433 | * | ||
434 | * \param pixel_format one of the SDL_PixelFormatEnum values | ||
435 | * \returns the new SDL_PixelFormat structure or NULL on failure; call | ||
436 | * SDL_GetError() for more information. | ||
437 | * | ||
438 | * \since This function is available since SDL 2.0.0. | ||
439 | * | ||
440 | * \sa SDL_FreeFormat | ||
441 | */ | ||
442 | extern DECLSPEC SDL_PixelFormat * SDLCALL SDL_AllocFormat(Uint32 pixel_format); | ||
443 | |||
444 | /** | ||
445 | * Free an SDL_PixelFormat structure allocated by SDL_AllocFormat(). | ||
446 | * | ||
447 | * \param format the SDL_PixelFormat structure to free | ||
448 | * | ||
449 | * \since This function is available since SDL 2.0.0. | ||
450 | * | ||
451 | * \sa SDL_AllocFormat | ||
452 | */ | ||
453 | extern DECLSPEC void SDLCALL SDL_FreeFormat(SDL_PixelFormat *format); | ||
454 | |||
455 | /** | ||
456 | * Create a palette structure with the specified number of color entries. | ||
457 | * | ||
458 | * The palette entries are initialized to white. | ||
459 | * | ||
460 | * \param ncolors represents the number of color entries in the color palette | ||
461 | * \returns a new SDL_Palette structure on success or NULL on failure (e.g. if | ||
462 | * there wasn't enough memory); call SDL_GetError() for more | ||
463 | * information. | ||
464 | * | ||
465 | * \since This function is available since SDL 2.0.0. | ||
466 | * | ||
467 | * \sa SDL_FreePalette | ||
468 | */ | ||
469 | extern DECLSPEC SDL_Palette *SDLCALL SDL_AllocPalette(int ncolors); | ||
470 | |||
471 | /** | ||
472 | * Set the palette for a pixel format structure. | ||
473 | * | ||
474 | * \param format the SDL_PixelFormat structure that will use the palette | ||
475 | * \param palette the SDL_Palette structure that will be used | ||
476 | * \returns 0 on success or a negative error code on failure; call | ||
477 | * SDL_GetError() for more information. | ||
478 | * | ||
479 | * \since This function is available since SDL 2.0.0. | ||
480 | * | ||
481 | * \sa SDL_AllocPalette | ||
482 | * \sa SDL_FreePalette | ||
483 | */ | ||
484 | extern DECLSPEC int SDLCALL SDL_SetPixelFormatPalette(SDL_PixelFormat * format, | ||
485 | SDL_Palette *palette); | ||
486 | |||
487 | /** | ||
488 | * Set a range of colors in a palette. | ||
489 | * | ||
490 | * \param palette the SDL_Palette structure to modify | ||
491 | * \param colors an array of SDL_Color structures to copy into the palette | ||
492 | * \param firstcolor the index of the first palette entry to modify | ||
493 | * \param ncolors the number of entries to modify | ||
494 | * \returns 0 on success or a negative error code if not all of the colors | ||
495 | * could be set; call SDL_GetError() for more information. | ||
496 | * | ||
497 | * \since This function is available since SDL 2.0.0. | ||
498 | * | ||
499 | * \sa SDL_AllocPalette | ||
500 | * \sa SDL_CreateRGBSurface | ||
501 | */ | ||
502 | extern DECLSPEC int SDLCALL SDL_SetPaletteColors(SDL_Palette * palette, | ||
503 | const SDL_Color * colors, | ||
504 | int firstcolor, int ncolors); | ||
505 | |||
506 | /** | ||
507 | * Free a palette created with SDL_AllocPalette(). | ||
508 | * | ||
509 | * \param palette the SDL_Palette structure to be freed | ||
510 | * | ||
511 | * \since This function is available since SDL 2.0.0. | ||
512 | * | ||
513 | * \sa SDL_AllocPalette | ||
514 | */ | ||
515 | extern DECLSPEC void SDLCALL SDL_FreePalette(SDL_Palette * palette); | ||
516 | |||
517 | /** | ||
518 | * Map an RGB triple to an opaque pixel value for a given pixel format. | ||
519 | * | ||
520 | * This function maps the RGB color value to the specified pixel format and | ||
521 | * returns the pixel value best approximating the given RGB color value for | ||
522 | * the given pixel format. | ||
523 | * | ||
524 | * If the format has a palette (8-bit) the index of the closest matching color | ||
525 | * in the palette will be returned. | ||
526 | * | ||
527 | * If the specified pixel format has an alpha component it will be returned as | ||
528 | * all 1 bits (fully opaque). | ||
529 | * | ||
530 | * If the pixel format bpp (color depth) is less than 32-bpp then the unused | ||
531 | * upper bits of the return value can safely be ignored (e.g., with a 16-bpp | ||
532 | * format the return value can be assigned to a Uint16, and similarly a Uint8 | ||
533 | * for an 8-bpp format). | ||
534 | * | ||
535 | * \param format an SDL_PixelFormat structure describing the pixel format | ||
536 | * \param r the red component of the pixel in the range 0-255 | ||
537 | * \param g the green component of the pixel in the range 0-255 | ||
538 | * \param b the blue component of the pixel in the range 0-255 | ||
539 | * \returns a pixel value | ||
540 | * | ||
541 | * \since This function is available since SDL 2.0.0. | ||
542 | * | ||
543 | * \sa SDL_GetRGB | ||
544 | * \sa SDL_GetRGBA | ||
545 | * \sa SDL_MapRGBA | ||
546 | */ | ||
547 | extern DECLSPEC Uint32 SDLCALL SDL_MapRGB(const SDL_PixelFormat * format, | ||
548 | Uint8 r, Uint8 g, Uint8 b); | ||
549 | |||
550 | /** | ||
551 | * Map an RGBA quadruple to a pixel value for a given pixel format. | ||
552 | * | ||
553 | * This function maps the RGBA color value to the specified pixel format and | ||
554 | * returns the pixel value best approximating the given RGBA color value for | ||
555 | * the given pixel format. | ||
556 | * | ||
557 | * If the specified pixel format has no alpha component the alpha value will | ||
558 | * be ignored (as it will be in formats with a palette). | ||
559 | * | ||
560 | * If the format has a palette (8-bit) the index of the closest matching color | ||
561 | * in the palette will be returned. | ||
562 | * | ||
563 | * If the pixel format bpp (color depth) is less than 32-bpp then the unused | ||
564 | * upper bits of the return value can safely be ignored (e.g., with a 16-bpp | ||
565 | * format the return value can be assigned to a Uint16, and similarly a Uint8 | ||
566 | * for an 8-bpp format). | ||
567 | * | ||
568 | * \param format an SDL_PixelFormat structure describing the format of the | ||
569 | * pixel | ||
570 | * \param r the red component of the pixel in the range 0-255 | ||
571 | * \param g the green component of the pixel in the range 0-255 | ||
572 | * \param b the blue component of the pixel in the range 0-255 | ||
573 | * \param a the alpha component of the pixel in the range 0-255 | ||
574 | * \returns a pixel value | ||
575 | * | ||
576 | * \since This function is available since SDL 2.0.0. | ||
577 | * | ||
578 | * \sa SDL_GetRGB | ||
579 | * \sa SDL_GetRGBA | ||
580 | * \sa SDL_MapRGB | ||
581 | */ | ||
582 | extern DECLSPEC Uint32 SDLCALL SDL_MapRGBA(const SDL_PixelFormat * format, | ||
583 | Uint8 r, Uint8 g, Uint8 b, | ||
584 | Uint8 a); | ||
585 | |||
586 | /** | ||
587 | * Get RGB values from a pixel in the specified format. | ||
588 | * | ||
589 | * This function uses the entire 8-bit [0..255] range when converting color | ||
590 | * components from pixel formats with less than 8-bits per RGB component | ||
591 | * (e.g., a completely white pixel in 16-bit RGB565 format would return [0xff, | ||
592 | * 0xff, 0xff] not [0xf8, 0xfc, 0xf8]). | ||
593 | * | ||
594 | * \param pixel a pixel value | ||
595 | * \param format an SDL_PixelFormat structure describing the format of the | ||
596 | * pixel | ||
597 | * \param r a pointer filled in with the red component | ||
598 | * \param g a pointer filled in with the green component | ||
599 | * \param b a pointer filled in with the blue component | ||
600 | * | ||
601 | * \since This function is available since SDL 2.0.0. | ||
602 | * | ||
603 | * \sa SDL_GetRGBA | ||
604 | * \sa SDL_MapRGB | ||
605 | * \sa SDL_MapRGBA | ||
606 | */ | ||
607 | extern DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixel, | ||
608 | const SDL_PixelFormat * format, | ||
609 | Uint8 * r, Uint8 * g, Uint8 * b); | ||
610 | |||
611 | /** | ||
612 | * Get RGBA values from a pixel in the specified format. | ||
613 | * | ||
614 | * This function uses the entire 8-bit [0..255] range when converting color | ||
615 | * components from pixel formats with less than 8-bits per RGB component | ||
616 | * (e.g., a completely white pixel in 16-bit RGB565 format would return [0xff, | ||
617 | * 0xff, 0xff] not [0xf8, 0xfc, 0xf8]). | ||
618 | * | ||
619 | * If the surface has no alpha component, the alpha will be returned as 0xff | ||
620 | * (100% opaque). | ||
621 | * | ||
622 | * \param pixel a pixel value | ||
623 | * \param format an SDL_PixelFormat structure describing the format of the | ||
624 | * pixel | ||
625 | * \param r a pointer filled in with the red component | ||
626 | * \param g a pointer filled in with the green component | ||
627 | * \param b a pointer filled in with the blue component | ||
628 | * \param a a pointer filled in with the alpha component | ||
629 | * | ||
630 | * \since This function is available since SDL 2.0.0. | ||
631 | * | ||
632 | * \sa SDL_GetRGB | ||
633 | * \sa SDL_MapRGB | ||
634 | * \sa SDL_MapRGBA | ||
635 | */ | ||
636 | extern DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel, | ||
637 | const SDL_PixelFormat * format, | ||
638 | Uint8 * r, Uint8 * g, Uint8 * b, | ||
639 | Uint8 * a); | ||
640 | |||
641 | /** | ||
642 | * Calculate a 256 entry gamma ramp for a gamma value. | ||
643 | * | ||
644 | * \param gamma a gamma value where 0.0 is black and 1.0 is identity | ||
645 | * \param ramp an array of 256 values filled in with the gamma ramp | ||
646 | * | ||
647 | * \since This function is available since SDL 2.0.0. | ||
648 | * | ||
649 | * \sa SDL_SetWindowGammaRamp | ||
650 | */ | ||
651 | extern DECLSPEC void SDLCALL SDL_CalculateGammaRamp(float gamma, Uint16 * ramp); | ||
652 | |||
653 | |||
654 | /* Ends C function definitions when using C++ */ | ||
655 | #ifdef __cplusplus | ||
656 | } | ||
657 | #endif | ||
658 | #include "close_code.h" | ||
659 | |||
660 | #endif /* SDL_pixels_h_ */ | ||
661 | |||
662 | /* vi: set ts=4 sw=4 expandtab: */ | ||