SDL 3.0
SDL_pixels.h
Go to the documentation of this file.
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2025 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 * # CategoryPixels
24 *
25 * SDL offers facilities for pixel management.
26 *
27 * Largely these facilities deal with pixel _format_: what does this set of
28 * bits represent?
29 *
30 * If you mostly want to think of a pixel as some combination of red, green,
31 * blue, and maybe alpha intensities, this is all pretty straightforward, and
32 * in many cases, is enough information to build a perfectly fine game.
33 *
34 * However, the actual definition of a pixel is more complex than that:
35 *
36 * Pixels are a representation of a color in a particular color space.
37 *
38 * The first characteristic of a color space is the color type. SDL
39 * understands two different color types, RGB and YCbCr, or in SDL also
40 * referred to as YUV.
41 *
42 * RGB colors consist of red, green, and blue channels of color that are added
43 * together to represent the colors we see on the screen.
44 *
45 * https://en.wikipedia.org/wiki/RGB_color_model
46 *
47 * YCbCr colors represent colors as a Y luma brightness component and red and
48 * blue chroma color offsets. This color representation takes advantage of the
49 * fact that the human eye is more sensitive to brightness than the color in
50 * an image. The Cb and Cr components are often compressed and have lower
51 * resolution than the luma component.
52 *
53 * https://en.wikipedia.org/wiki/YCbCr
54 *
55 * When the color information in YCbCr is compressed, the Y pixels are left at
56 * full resolution and each Cr and Cb pixel represents an average of the color
57 * information in a block of Y pixels. The chroma location determines where in
58 * that block of pixels the color information is coming from.
59 *
60 * The color range defines how much of the pixel to use when converting a
61 * pixel into a color on the display. When the full color range is used, the
62 * entire numeric range of the pixel bits is significant. When narrow color
63 * range is used, for historical reasons, the pixel uses only a portion of the
64 * numeric range to represent colors.
65 *
66 * The color primaries and white point are a definition of the colors in the
67 * color space relative to the standard XYZ color space.
68 *
69 * https://en.wikipedia.org/wiki/CIE_1931_color_space
70 *
71 * The transfer characteristic, or opto-electrical transfer function (OETF),
72 * is the way a color is converted from mathematically linear space into a
73 * non-linear output signals.
74 *
75 * https://en.wikipedia.org/wiki/Rec._709#Transfer_characteristics
76 *
77 * The matrix coefficients are used to convert between YCbCr and RGB colors.
78 */
79
80#ifndef SDL_pixels_h_
81#define SDL_pixels_h_
82
83#include <SDL3/SDL_stdinc.h>
84#include <SDL3/SDL_error.h>
85#include <SDL3/SDL_endian.h>
86
87#include <SDL3/SDL_begin_code.h>
88/* Set up for C function definitions, even when using C++ */
89#ifdef __cplusplus
90extern "C" {
91#endif
92
93/**
94 * A fully opaque 8-bit alpha value.
95 *
96 * \since This macro is available since SDL 3.1.3.
97 *
98 * \sa SDL_ALPHA_TRANSPARENT
99 */
100#define SDL_ALPHA_OPAQUE 255
101
102/**
103 * A fully opaque floating point alpha value.
104 *
105 * \since This macro is available since SDL 3.1.3.
106 *
107 * \sa SDL_ALPHA_TRANSPARENT_FLOAT
108 */
109#define SDL_ALPHA_OPAQUE_FLOAT 1.0f
110
111/**
112 * A fully transparent 8-bit alpha value.
113 *
114 * \since This macro is available since SDL 3.1.3.
115 *
116 * \sa SDL_ALPHA_OPAQUE
117 */
118#define SDL_ALPHA_TRANSPARENT 0
119
120/**
121 * A fully transparent floating point alpha value.
122 *
123 * \since This macro is available since SDL 3.1.3.
124 *
125 * \sa SDL_ALPHA_OPAQUE_FLOAT
126 */
127#define SDL_ALPHA_TRANSPARENT_FLOAT 0.0f
128
129/**
130 * Pixel type.
131 *
132 * \since This enum is available since SDL 3.1.3.
133 */
151
152/**
153 * Bitmap pixel order, high bit -> low bit.
154 *
155 * \since This enum is available since SDL 3.1.3.
156 */
163
164/**
165 * Packed component order, high bit -> low bit.
166 *
167 * \since This enum is available since SDL 3.1.3.
168 */
181
182/**
183 * Array component order, low byte -> high byte.
184 *
185 * \since This enum is available since SDL 3.1.3.
186 */
197
198/**
199 * Packed component layout.
200 *
201 * \since This enum is available since SDL 3.1.3.
202 */
215
216/**
217 * A macro for defining custom FourCC pixel formats.
218 *
219 * For example, defining SDL_PIXELFORMAT_YV12 looks like this:
220 *
221 * ```c
222 * SDL_DEFINE_PIXELFOURCC('Y', 'V', '1', '2')
223 * ```
224 *
225 * \param A the first character of the FourCC code.
226 * \param B the second character of the FourCC code.
227 * \param C the third character of the FourCC code.
228 * \param D the fourth character of the FourCC code.
229 * \returns a format value in the style of SDL_PixelFormat.
230 *
231 * \threadsafety It is safe to call this macro from any thread.
232 *
233 * \since This macro is available since SDL 3.1.3.
234 */
235#define SDL_DEFINE_PIXELFOURCC(A, B, C, D) SDL_FOURCC(A, B, C, D)
236
237/**
238 * A macro for defining custom non-FourCC pixel formats.
239 *
240 * For example, defining SDL_PIXELFORMAT_RGBA8888 looks like this:
241 *
242 * ```c
243 * SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBA, SDL_PACKEDLAYOUT_8888, 32, 4)
244 * ```
245 *
246 * \param type the type of the new format, probably a SDL_PixelType value.
247 * \param order the order of the new format, probably a SDL_BitmapOrder,
248 * SDL_PackedOrder, or SDL_ArrayOrder value.
249 * \param layout the layout of the new format, probably an SDL_PackedLayout
250 * value or zero.
251 * \param bits the number of bits per pixel of the new format.
252 * \param bytes the number of bytes per pixel of the new format.
253 * \returns a format value in the style of SDL_PixelFormat.
254 *
255 * \threadsafety It is safe to call this macro from any thread.
256 *
257 * \since This macro is available since SDL 3.1.3.
258 */
259#define SDL_DEFINE_PIXELFORMAT(type, order, layout, bits, bytes) \
260 ((1 << 28) | ((type) << 24) | ((order) << 20) | ((layout) << 16) | \
261 ((bits) << 8) | ((bytes) << 0))
262
263/**
264 * A macro to retrieve the flags of an SDL_PixelFormat.
265 *
266 * This macro is generally not needed directly by an app, which should use
267 * specific tests, like SDL_ISPIXELFORMAT_FOURCC, instead.
268 *
269 * \param format an SDL_PixelFormat to check.
270 * \returns the flags of `format`.
271 *
272 * \threadsafety It is safe to call this macro from any thread.
273 *
274 * \since This macro is available since SDL 3.1.3.
275 */
276#define SDL_PIXELFLAG(format) (((format) >> 28) & 0x0F)
277
278/**
279 * A macro to retrieve the type of an SDL_PixelFormat.
280 *
281 * This is usually a value from the SDL_PixelType enumeration.
282 *
283 * \param format an SDL_PixelFormat to check.
284 * \returns the type of `format`.
285 *
286 * \threadsafety It is safe to call this macro from any thread.
287 *
288 * \since This macro is available since SDL 3.1.3.
289 */
290#define SDL_PIXELTYPE(format) (((format) >> 24) & 0x0F)
291
292/**
293 * A macro to retrieve the order of an SDL_PixelFormat.
294 *
295 * This is usually a value from the SDL_BitmapOrder, SDL_PackedOrder, or
296 * SDL_ArrayOrder enumerations, depending on the format type.
297 *
298 * \param format an SDL_PixelFormat to check.
299 * \returns the order of `format`.
300 *
301 * \threadsafety It is safe to call this macro from any thread.
302 *
303 * \since This macro is available since SDL 3.1.3.
304 */
305#define SDL_PIXELORDER(format) (((format) >> 20) & 0x0F)
306
307/**
308 * A macro to retrieve the layout of an SDL_PixelFormat.
309 *
310 * This is usually a value from the SDL_PackedLayout enumeration, or zero if a
311 * layout doesn't make sense for the format type.
312 *
313 * \param format an SDL_PixelFormat to check.
314 * \returns the layout of `format`.
315 *
316 * \threadsafety It is safe to call this macro from any thread.
317 *
318 * \since This macro is available since SDL 3.1.3.
319 */
320#define SDL_PIXELLAYOUT(format) (((format) >> 16) & 0x0F)
321
322/**
323 * A macro to determine an SDL_PixelFormat's bits per pixel.
324 *
325 * Note that this macro double-evaluates its parameter, so do not use
326 * expressions with side-effects here.
327 *
328 * FourCC formats will report zero here, as it rarely makes sense to measure
329 * them per-pixel.
330 *
331 * \param format an SDL_PixelFormat to check.
332 * \returns the bits-per-pixel of `format`.
333 *
334 * \threadsafety It is safe to call this macro from any thread.
335 *
336 * \since This macro is available since SDL 3.1.3.
337 *
338 * \sa SDL_BYTESPERPIXEL
339 */
340#define SDL_BITSPERPIXEL(format) \
341 (SDL_ISPIXELFORMAT_FOURCC(format) ? 0 : (((format) >> 8) & 0xFF))
342
343/**
344 * A macro to determine an SDL_PixelFormat's bytes per pixel.
345 *
346 * Note that this macro double-evaluates its parameter, so do not use
347 * expressions with side-effects here.
348 *
349 * FourCC formats do their best here, but many of them don't have a meaningful
350 * measurement of bytes per pixel.
351 *
352 * \param format an SDL_PixelFormat to check.
353 * \returns the bytes-per-pixel of `format`.
354 *
355 * \threadsafety It is safe to call this macro from any thread.
356 *
357 * \since This macro is available since SDL 3.1.3.
358 *
359 * \sa SDL_BITSPERPIXEL
360 */
361#define SDL_BYTESPERPIXEL(format) \
362 (SDL_ISPIXELFORMAT_FOURCC(format) ? \
363 ((((format) == SDL_PIXELFORMAT_YUY2) || \
364 ((format) == SDL_PIXELFORMAT_UYVY) || \
365 ((format) == SDL_PIXELFORMAT_YVYU) || \
366 ((format) == SDL_PIXELFORMAT_P010)) ? 2 : 1) : (((format) >> 0) & 0xFF))
367
368
369/**
370 * A macro to determine if an SDL_PixelFormat is an indexed format.
371 *
372 * Note that this macro double-evaluates its parameter, so do not use
373 * expressions with side-effects here.
374 *
375 * \param format an SDL_PixelFormat to check.
376 * \returns true if the format is indexed, false otherwise.
377 *
378 * \threadsafety It is safe to call this macro from any thread.
379 *
380 * \since This macro is available since SDL 3.1.3.
381 */
382#define SDL_ISPIXELFORMAT_INDEXED(format) \
383 (!SDL_ISPIXELFORMAT_FOURCC(format) && \
384 ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX1) || \
385 (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX2) || \
386 (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX4) || \
387 (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX8)))
388
389/**
390 * A macro to determine if an SDL_PixelFormat is a packed format.
391 *
392 * Note that this macro double-evaluates its parameter, so do not use
393 * expressions with side-effects here.
394 *
395 * \param format an SDL_PixelFormat to check.
396 * \returns true if the format is packed, false otherwise.
397 *
398 * \threadsafety It is safe to call this macro from any thread.
399 *
400 * \since This macro is available since SDL 3.1.3.
401 */
402#define SDL_ISPIXELFORMAT_PACKED(format) \
403 (!SDL_ISPIXELFORMAT_FOURCC(format) && \
404 ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_PACKED8) || \
405 (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_PACKED16) || \
406 (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_PACKED32)))
407
408/**
409 * A macro to determine if an SDL_PixelFormat is an array format.
410 *
411 * Note that this macro double-evaluates its parameter, so do not use
412 * expressions with side-effects here.
413 *
414 * \param format an SDL_PixelFormat to check.
415 * \returns true if the format is an array, false otherwise.
416 *
417 * \threadsafety It is safe to call this macro from any thread.
418 *
419 * \since This macro is available since SDL 3.1.3.
420 */
421#define SDL_ISPIXELFORMAT_ARRAY(format) \
422 (!SDL_ISPIXELFORMAT_FOURCC(format) && \
423 ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYU8) || \
424 (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYU16) || \
425 (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYU32) || \
426 (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYF16) || \
427 (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYF32)))
428
429/**
430 * A macro to determine if an SDL_PixelFormat is a 10-bit format.
431 *
432 * Note that this macro double-evaluates its parameter, so do not use
433 * expressions with side-effects here.
434 *
435 * \param format an SDL_PixelFormat to check.
436 * \returns true if the format is 10-bit, false otherwise.
437 *
438 * \threadsafety It is safe to call this macro from any thread.
439 *
440 * \since This macro is available since SDL 3.1.3.
441 */
442#define SDL_ISPIXELFORMAT_10BIT(format) \
443 (!SDL_ISPIXELFORMAT_FOURCC(format) && \
444 ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_PACKED32) && \
445 (SDL_PIXELLAYOUT(format) == SDL_PACKEDLAYOUT_2101010)))
446
447/**
448 * A macro to determine if an SDL_PixelFormat is a floating point format.
449 *
450 * Note that this macro double-evaluates its parameter, so do not use
451 * expressions with side-effects here.
452 *
453 * \param format an SDL_PixelFormat to check.
454 * \returns true if the format is 10-bit, false otherwise.
455 *
456 * \threadsafety It is safe to call this macro from any thread.
457 *
458 * \since This macro is available since SDL 3.1.3.
459 */
460#define SDL_ISPIXELFORMAT_FLOAT(format) \
461 (!SDL_ISPIXELFORMAT_FOURCC(format) && \
462 ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYF16) || \
463 (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYF32)))
464
465/**
466 * A macro to determine if an SDL_PixelFormat has an alpha channel.
467 *
468 * Note that this macro double-evaluates its parameter, so do not use
469 * expressions with side-effects here.
470 *
471 * \param format an SDL_PixelFormat to check.
472 * \returns true if the format has alpha, false otherwise.
473 *
474 * \threadsafety It is safe to call this macro from any thread.
475 *
476 * \since This macro is available since SDL 3.1.3.
477 */
478#define SDL_ISPIXELFORMAT_ALPHA(format) \
479 ((SDL_ISPIXELFORMAT_PACKED(format) && \
480 ((SDL_PIXELORDER(format) == SDL_PACKEDORDER_ARGB) || \
481 (SDL_PIXELORDER(format) == SDL_PACKEDORDER_RGBA) || \
482 (SDL_PIXELORDER(format) == SDL_PACKEDORDER_ABGR) || \
483 (SDL_PIXELORDER(format) == SDL_PACKEDORDER_BGRA))) || \
484 (SDL_ISPIXELFORMAT_ARRAY(format) && \
485 ((SDL_PIXELORDER(format) == SDL_ARRAYORDER_ARGB) || \
486 (SDL_PIXELORDER(format) == SDL_ARRAYORDER_RGBA) || \
487 (SDL_PIXELORDER(format) == SDL_ARRAYORDER_ABGR) || \
488 (SDL_PIXELORDER(format) == SDL_ARRAYORDER_BGRA))))
489
490
491/**
492 * A macro to determine if an SDL_PixelFormat is a "FourCC" format.
493 *
494 * This covers custom and other unusual formats.
495 *
496 * Note that this macro double-evaluates its parameter, so do not use
497 * expressions with side-effects here.
498 *
499 * \param format an SDL_PixelFormat to check.
500 * \returns true if the format has alpha, false otherwise.
501 *
502 * \threadsafety It is safe to call this macro from any thread.
503 *
504 * \since This macro is available since SDL 3.1.3.
505 */
506#define SDL_ISPIXELFORMAT_FOURCC(format) /* The flag is set to 1 because 0x1? is not in the printable ASCII range */ \
507 ((format) && (SDL_PIXELFLAG(format) != 1))
508
509/* Note: If you modify this enum, update SDL_GetPixelFormatName() */
510
511/**
512 * Pixel format.
513 *
514 * SDL's pixel formats have the following naming convention:
515 *
516 * - Names with a list of components and a single bit count, such as RGB24 and
517 * ABGR32, define a platform-independent encoding into bytes in the order
518 * specified. For example, in RGB24 data, each pixel is encoded in 3 bytes
519 * (red, green, blue) in that order, and in ABGR32 data, each pixel is
520 * encoded in 4 bytes alpha, blue, green, red) in that order. Use these
521 * names if the property of a format that is important to you is the order
522 * of the bytes in memory or on disk.
523 * - Names with a bit count per component, such as ARGB8888 and XRGB1555, are
524 * "packed" into an appropriately-sized integer in the platform's native
525 * endianness. For example, ARGB8888 is a sequence of 32-bit integers; in
526 * each integer, the most significant bits are alpha, and the least
527 * significant bits are blue. On a little-endian CPU such as x86, the least
528 * significant bits of each integer are arranged first in memory, but on a
529 * big-endian CPU such as s390x, the most significant bits are arranged
530 * first. Use these names if the property of a format that is important to
531 * you is the meaning of each bit position within a native-endianness
532 * integer.
533 * - In indexed formats such as INDEX4LSB, each pixel is represented by
534 * encoding an index into the palette into the indicated number of bits,
535 * with multiple pixels packed into each byte if appropriate. In LSB
536 * formats, the first (leftmost) pixel is stored in the least-significant
537 * bits of the byte; in MSB formats, it's stored in the most-significant
538 * bits. INDEX8 does not need LSB/MSB variants, because each pixel exactly
539 * fills one byte.
540 *
541 * The 32-bit byte-array encodings such as RGBA32 are aliases for the
542 * appropriate 8888 encoding for the current platform. For example, RGBA32 is
543 * an alias for ABGR8888 on little-endian CPUs like x86, or an alias for
544 * RGBA8888 on big-endian CPUs.
545 *
546 * \since This enum is available since SDL 3.1.3.
547 */
548typedef enum SDL_PixelFormat
549{
552 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_4321, 0, 1, 0), */
554 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_1234, 0, 1, 0), */
556 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX2, SDL_BITMAPORDER_4321, 0, 2, 0), */
558 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX2, SDL_BITMAPORDER_1234, 0, 2, 0), */
560 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_4321, 0, 4, 0), */
562 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_1234, 0, 4, 0), */
564 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX8, 0, 0, 8, 1), */
566 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED8, SDL_PACKEDORDER_XRGB, SDL_PACKEDLAYOUT_332, 8, 1), */
568 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB, SDL_PACKEDLAYOUT_4444, 12, 2), */
570 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR, SDL_PACKEDLAYOUT_4444, 12, 2), */
572 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB, SDL_PACKEDLAYOUT_1555, 15, 2), */
574 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR, SDL_PACKEDLAYOUT_1555, 15, 2), */
576 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ARGB, SDL_PACKEDLAYOUT_4444, 16, 2), */
578 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_RGBA, SDL_PACKEDLAYOUT_4444, 16, 2), */
580 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ABGR, SDL_PACKEDLAYOUT_4444, 16, 2), */
582 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_BGRA, SDL_PACKEDLAYOUT_4444, 16, 2), */
584 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ARGB, SDL_PACKEDLAYOUT_1555, 16, 2), */
586 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_RGBA, SDL_PACKEDLAYOUT_5551, 16, 2), */
588 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ABGR, SDL_PACKEDLAYOUT_1555, 16, 2), */
590 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_BGRA, SDL_PACKEDLAYOUT_5551, 16, 2), */
592 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB, SDL_PACKEDLAYOUT_565, 16, 2), */
594 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR, SDL_PACKEDLAYOUT_565, 16, 2), */
596 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_RGB, 0, 24, 3), */
598 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_BGR, 0, 24, 3), */
600 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XRGB, SDL_PACKEDLAYOUT_8888, 24, 4), */
602 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBX, SDL_PACKEDLAYOUT_8888, 24, 4), */
604 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XBGR, SDL_PACKEDLAYOUT_8888, 24, 4), */
606 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_BGRX, SDL_PACKEDLAYOUT_8888, 24, 4), */
608 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ARGB, SDL_PACKEDLAYOUT_8888, 32, 4), */
610 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBA, SDL_PACKEDLAYOUT_8888, 32, 4), */
612 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ABGR, SDL_PACKEDLAYOUT_8888, 32, 4), */
614 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_BGRA, SDL_PACKEDLAYOUT_8888, 32, 4), */
616 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XRGB, SDL_PACKEDLAYOUT_2101010, 32, 4), */
618 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XBGR, SDL_PACKEDLAYOUT_2101010, 32, 4), */
620 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ARGB, SDL_PACKEDLAYOUT_2101010, 32, 4), */
622 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ABGR, SDL_PACKEDLAYOUT_2101010, 32, 4), */
624 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU16, SDL_ARRAYORDER_RGB, 0, 48, 6), */
626 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU16, SDL_ARRAYORDER_BGR, 0, 48, 6), */
628 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU16, SDL_ARRAYORDER_RGBA, 0, 64, 8), */
630 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU16, SDL_ARRAYORDER_ARGB, 0, 64, 8), */
632 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU16, SDL_ARRAYORDER_BGRA, 0, 64, 8), */
634 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU16, SDL_ARRAYORDER_ABGR, 0, 64, 8), */
636 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF16, SDL_ARRAYORDER_RGB, 0, 48, 6), */
638 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF16, SDL_ARRAYORDER_BGR, 0, 48, 6), */
640 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF16, SDL_ARRAYORDER_RGBA, 0, 64, 8), */
642 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF16, SDL_ARRAYORDER_ARGB, 0, 64, 8), */
644 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF16, SDL_ARRAYORDER_BGRA, 0, 64, 8), */
646 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF16, SDL_ARRAYORDER_ABGR, 0, 64, 8), */
648 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF32, SDL_ARRAYORDER_RGB, 0, 96, 12), */
650 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF32, SDL_ARRAYORDER_BGR, 0, 96, 12), */
652 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF32, SDL_ARRAYORDER_RGBA, 0, 128, 16), */
654 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF32, SDL_ARRAYORDER_ARGB, 0, 128, 16), */
656 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF32, SDL_ARRAYORDER_BGRA, 0, 128, 16), */
658 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF32, SDL_ARRAYORDER_ABGR, 0, 128, 16), */
659
660 SDL_PIXELFORMAT_YV12 = 0x32315659u, /**< Planar mode: Y + V + U (3 planes) */
661 /* SDL_DEFINE_PIXELFOURCC('Y', 'V', '1', '2'), */
662 SDL_PIXELFORMAT_IYUV = 0x56555949u, /**< Planar mode: Y + U + V (3 planes) */
663 /* SDL_DEFINE_PIXELFOURCC('I', 'Y', 'U', 'V'), */
664 SDL_PIXELFORMAT_YUY2 = 0x32595559u, /**< Packed mode: Y0+U0+Y1+V0 (1 plane) */
665 /* SDL_DEFINE_PIXELFOURCC('Y', 'U', 'Y', '2'), */
666 SDL_PIXELFORMAT_UYVY = 0x59565955u, /**< Packed mode: U0+Y0+V0+Y1 (1 plane) */
667 /* SDL_DEFINE_PIXELFOURCC('U', 'Y', 'V', 'Y'), */
668 SDL_PIXELFORMAT_YVYU = 0x55595659u, /**< Packed mode: Y0+V0+Y1+U0 (1 plane) */
669 /* SDL_DEFINE_PIXELFOURCC('Y', 'V', 'Y', 'U'), */
670 SDL_PIXELFORMAT_NV12 = 0x3231564eu, /**< Planar mode: Y + U/V interleaved (2 planes) */
671 /* SDL_DEFINE_PIXELFOURCC('N', 'V', '1', '2'), */
672 SDL_PIXELFORMAT_NV21 = 0x3132564eu, /**< Planar mode: Y + V/U interleaved (2 planes) */
673 /* SDL_DEFINE_PIXELFOURCC('N', 'V', '2', '1'), */
674 SDL_PIXELFORMAT_P010 = 0x30313050u, /**< Planar mode: Y + U/V interleaved (2 planes) */
675 /* SDL_DEFINE_PIXELFOURCC('P', '0', '1', '0'), */
676 SDL_PIXELFORMAT_EXTERNAL_OES = 0x2053454fu, /**< Android video texture format */
677 /* SDL_DEFINE_PIXELFOURCC('O', 'E', 'S', ' ') */
678
679 /* Aliases for RGBA byte arrays of color data, for the current platform */
680 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
689 #else
698 #endif
700
701/**
702 * Colorspace color type.
703 *
704 * \since This enum is available since SDL 3.1.3.
705 */
712
713/**
714 * Colorspace color range, as described by
715 * https://www.itu.int/rec/R-REC-BT.2100-2-201807-I/en
716 *
717 * \since This enum is available since SDL 3.1.3.
718 */
719typedef enum SDL_ColorRange
720{
722 SDL_COLOR_RANGE_LIMITED = 1, /**< Narrow range, e.g. 16-235 for 8-bit RGB and luma, and 16-240 for 8-bit chroma */
723 SDL_COLOR_RANGE_FULL = 2 /**< Full range, e.g. 0-255 for 8-bit RGB and luma, and 1-255 for 8-bit chroma */
725
726/**
727 * Colorspace color primaries, as described by
728 * https://www.itu.int/rec/T-REC-H.273-201612-S/en
729 *
730 * \since This enum is available since SDL 3.1.3.
731 */
733{
735 SDL_COLOR_PRIMARIES_BT709 = 1, /**< ITU-R BT.709-6 */
737 SDL_COLOR_PRIMARIES_BT470M = 4, /**< ITU-R BT.470-6 System M */
738 SDL_COLOR_PRIMARIES_BT470BG = 5, /**< ITU-R BT.470-6 System B, G / ITU-R BT.601-7 625 */
739 SDL_COLOR_PRIMARIES_BT601 = 6, /**< ITU-R BT.601-7 525, SMPTE 170M */
740 SDL_COLOR_PRIMARIES_SMPTE240 = 7, /**< SMPTE 240M, functionally the same as SDL_COLOR_PRIMARIES_BT601 */
741 SDL_COLOR_PRIMARIES_GENERIC_FILM = 8, /**< Generic film (color filters using Illuminant C) */
742 SDL_COLOR_PRIMARIES_BT2020 = 9, /**< ITU-R BT.2020-2 / ITU-R BT.2100-0 */
743 SDL_COLOR_PRIMARIES_XYZ = 10, /**< SMPTE ST 428-1 */
744 SDL_COLOR_PRIMARIES_SMPTE431 = 11, /**< SMPTE RP 431-2 */
745 SDL_COLOR_PRIMARIES_SMPTE432 = 12, /**< SMPTE EG 432-1 / DCI P3 */
746 SDL_COLOR_PRIMARIES_EBU3213 = 22, /**< EBU Tech. 3213-E */
749
750/**
751 * Colorspace transfer characteristics.
752 *
753 * These are as described by https://www.itu.int/rec/T-REC-H.273-201612-S/en
754 *
755 * \since This enum is available since SDL 3.1.3.
756 */
758{
760 SDL_TRANSFER_CHARACTERISTICS_BT709 = 1, /**< Rec. ITU-R BT.709-6 / ITU-R BT1361 */
762 SDL_TRANSFER_CHARACTERISTICS_GAMMA22 = 4, /**< ITU-R BT.470-6 System M / ITU-R BT1700 625 PAL & SECAM */
763 SDL_TRANSFER_CHARACTERISTICS_GAMMA28 = 5, /**< ITU-R BT.470-6 System B, G */
764 SDL_TRANSFER_CHARACTERISTICS_BT601 = 6, /**< SMPTE ST 170M / ITU-R BT.601-7 525 or 625 */
765 SDL_TRANSFER_CHARACTERISTICS_SMPTE240 = 7, /**< SMPTE ST 240M */
769 SDL_TRANSFER_CHARACTERISTICS_IEC61966 = 11, /**< IEC 61966-2-4 */
770 SDL_TRANSFER_CHARACTERISTICS_BT1361 = 12, /**< ITU-R BT1361 Extended Colour Gamut */
771 SDL_TRANSFER_CHARACTERISTICS_SRGB = 13, /**< IEC 61966-2-1 (sRGB or sYCC) */
772 SDL_TRANSFER_CHARACTERISTICS_BT2020_10BIT = 14, /**< ITU-R BT2020 for 10-bit system */
773 SDL_TRANSFER_CHARACTERISTICS_BT2020_12BIT = 15, /**< ITU-R BT2020 for 12-bit system */
774 SDL_TRANSFER_CHARACTERISTICS_PQ = 16, /**< SMPTE ST 2084 for 10-, 12-, 14- and 16-bit systems */
775 SDL_TRANSFER_CHARACTERISTICS_SMPTE428 = 17, /**< SMPTE ST 428-1 */
776 SDL_TRANSFER_CHARACTERISTICS_HLG = 18, /**< ARIB STD-B67, known as "hybrid log-gamma" (HLG) */
779
780/**
781 * Colorspace matrix coefficients.
782 *
783 * These are as described by https://www.itu.int/rec/T-REC-H.273-201612-S/en
784 *
785 * \since This enum is available since SDL 3.1.3.
786 */
788{
790 SDL_MATRIX_COEFFICIENTS_BT709 = 1, /**< ITU-R BT.709-6 */
792 SDL_MATRIX_COEFFICIENTS_FCC = 4, /**< US FCC Title 47 */
793 SDL_MATRIX_COEFFICIENTS_BT470BG = 5, /**< ITU-R BT.470-6 System B, G / ITU-R BT.601-7 625, functionally the same as SDL_MATRIX_COEFFICIENTS_BT601 */
794 SDL_MATRIX_COEFFICIENTS_BT601 = 6, /**< ITU-R BT.601-7 525 */
795 SDL_MATRIX_COEFFICIENTS_SMPTE240 = 7, /**< SMPTE 240M */
797 SDL_MATRIX_COEFFICIENTS_BT2020_NCL = 9, /**< ITU-R BT.2020-2 non-constant luminance */
798 SDL_MATRIX_COEFFICIENTS_BT2020_CL = 10, /**< ITU-R BT.2020-2 constant luminance */
799 SDL_MATRIX_COEFFICIENTS_SMPTE2085 = 11, /**< SMPTE ST 2085 */
802 SDL_MATRIX_COEFFICIENTS_ICTCP = 14, /**< ITU-R BT.2100-0 ICTCP */
805
806/**
807 * Colorspace chroma sample location.
808 *
809 * \since This enum is available since SDL 3.1.3.
810 */
812{
813 SDL_CHROMA_LOCATION_NONE = 0, /**< RGB, no chroma sampling */
814 SDL_CHROMA_LOCATION_LEFT = 1, /**< In MPEG-2, MPEG-4, and AVC, Cb and Cr are taken on midpoint of the left-edge of the 2x2 square. In other words, they have the same horizontal location as the top-left pixel, but is shifted one-half pixel down vertically. */
815 SDL_CHROMA_LOCATION_CENTER = 2, /**< In JPEG/JFIF, H.261, and MPEG-1, Cb and Cr are taken at the center of the 2x2 square. In other words, they are offset one-half pixel to the right and one-half pixel down compared to the top-left pixel. */
816 SDL_CHROMA_LOCATION_TOPLEFT = 3 /**< In HEVC for BT.2020 and BT.2100 content (in particular on Blu-rays), Cb and Cr are sampled at the same location as the group's top-left Y pixel ("co-sited", "co-located"). */
818
819
820/* Colorspace definition */
821
822/**
823 * A macro for defining custom SDL_Colorspace formats.
824 *
825 * For example, defining SDL_COLORSPACE_SRGB looks like this:
826 *
827 * ```c
828 * SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_RGB,
829 * SDL_COLOR_RANGE_FULL,
830 * SDL_COLOR_PRIMARIES_BT709,
831 * SDL_TRANSFER_CHARACTERISTICS_SRGB,
832 * SDL_MATRIX_COEFFICIENTS_IDENTITY,
833 * SDL_CHROMA_LOCATION_NONE)
834 * ```
835 *
836 * \param type the type of the new format, probably an SDL_ColorType value.
837 * \param range the range of the new format, probably a SDL_ColorRange value.
838 * \param primaries the primaries of the new format, probably an
839 * SDL_ColorPrimaries value.
840 * \param transfer the transfer characteristics of the new format, probably an
841 * SDL_TransferCharacteristics value.
842 * \param matrix the matrix coefficients of the new format, probably an
843 * SDL_MatrixCoefficients value.
844 * \param chroma the chroma sample location of the new format, probably an
845 * SDL_ChromaLocation value.
846 * \returns a format value in the style of SDL_Colorspace.
847 *
848 * \threadsafety It is safe to call this macro from any thread.
849 *
850 * \since This macro is available since SDL 3.1.3.
851 */
852#define SDL_DEFINE_COLORSPACE(type, range, primaries, transfer, matrix, chroma) \
853 (((Uint32)(type) << 28) | ((Uint32)(range) << 24) | ((Uint32)(chroma) << 20) | \
854 ((Uint32)(primaries) << 10) | ((Uint32)(transfer) << 5) | ((Uint32)(matrix) << 0))
855
856/**
857 * A macro to retrieve the type of an SDL_Colorspace.
858 *
859 * \param cspace an SDL_Colorspace to check.
860 * \returns the SDL_ColorType for `cspace`.
861 *
862 * \threadsafety It is safe to call this macro from any thread.
863 *
864 * \since This macro is available since SDL 3.1.3.
865 */
866#define SDL_COLORSPACETYPE(cspace) (SDL_ColorType)(((cspace) >> 28) & 0x0F)
867
868/**
869 * A macro to retrieve the range of an SDL_Colorspace.
870 *
871 * \param cspace an SDL_Colorspace to check.
872 * \returns the SDL_ColorRange of `cspace`.
873 *
874 * \threadsafety It is safe to call this macro from any thread.
875 *
876 * \since This macro is available since SDL 3.1.3.
877 */
878#define SDL_COLORSPACERANGE(cspace) (SDL_ColorRange)(((cspace) >> 24) & 0x0F)
879
880/**
881 * A macro to retrieve the chroma sample location of an SDL_Colorspace.
882 *
883 * \param cspace an SDL_Colorspace to check.
884 * \returns the SDL_ChromaLocation of `cspace`.
885 *
886 * \threadsafety It is safe to call this macro from any thread.
887 *
888 * \since This macro is available since SDL 3.1.3.
889 */
890#define SDL_COLORSPACECHROMA(cspace) (SDL_ChromaLocation)(((cspace) >> 20) & 0x0F)
891
892/**
893 * A macro to retrieve the primaries of an SDL_Colorspace.
894 *
895 * \param cspace an SDL_Colorspace to check.
896 * \returns the SDL_ColorPrimaries of `cspace`.
897 *
898 * \threadsafety It is safe to call this macro from any thread.
899 *
900 * \since This macro is available since SDL 3.1.3.
901 */
902#define SDL_COLORSPACEPRIMARIES(cspace) (SDL_ColorPrimaries)(((cspace) >> 10) & 0x1F)
903
904/**
905 * A macro to retrieve the transfer characteristics of an SDL_Colorspace.
906 *
907 * \param cspace an SDL_Colorspace to check.
908 * \returns the SDL_TransferCharacteristics of `cspace`.
909 *
910 * \threadsafety It is safe to call this macro from any thread.
911 *
912 * \since This macro is available since SDL 3.1.3.
913 */
914#define SDL_COLORSPACETRANSFER(cspace) (SDL_TransferCharacteristics)(((cspace) >> 5) & 0x1F)
915
916/**
917 * A macro to retrieve the matrix coefficients of an SDL_Colorspace.
918 *
919 * \param cspace an SDL_Colorspace to check.
920 * \returns the SDL_MatrixCoefficients of `cspace`.
921 *
922 * \threadsafety It is safe to call this macro from any thread.
923 *
924 * \since This macro is available since SDL 3.1.3.
925 */
926#define SDL_COLORSPACEMATRIX(cspace) (SDL_MatrixCoefficients)((cspace) & 0x1F)
927
928/**
929 * A macro to determine if an SDL_Colorspace uses BT601 (or BT470BG) matrix
930 * coefficients.
931 *
932 * Note that this macro double-evaluates its parameter, so do not use
933 * expressions with side-effects here.
934 *
935 * \param cspace an SDL_Colorspace to check.
936 * \returns true if BT601 or BT470BG, false otherwise.
937 *
938 * \threadsafety It is safe to call this macro from any thread.
939 *
940 * \since This macro is available since SDL 3.1.3.
941 */
942#define SDL_ISCOLORSPACE_MATRIX_BT601(cspace) (SDL_COLORSPACEMATRIX(cspace) == SDL_MATRIX_COEFFICIENTS_BT601 || SDL_COLORSPACEMATRIX(cspace) == SDL_MATRIX_COEFFICIENTS_BT470BG)
943
944/**
945 * A macro to determine if an SDL_Colorspace uses BT709 matrix coefficients.
946 *
947 * \param cspace an SDL_Colorspace to check.
948 * \returns true if BT709, false otherwise.
949 *
950 * \threadsafety It is safe to call this macro from any thread.
951 *
952 * \since This macro is available since SDL 3.1.3.
953 */
954#define SDL_ISCOLORSPACE_MATRIX_BT709(cspace) (SDL_COLORSPACEMATRIX(cspace) == SDL_MATRIX_COEFFICIENTS_BT709)
955
956/**
957 * A macro to determine if an SDL_Colorspace uses BT2020_NCL matrix
958 * coefficients.
959 *
960 * \param cspace an SDL_Colorspace to check.
961 * \returns true if BT2020_NCL, false otherwise.
962 *
963 * \threadsafety It is safe to call this macro from any thread.
964 *
965 * \since This macro is available since SDL 3.1.3.
966 */
967#define SDL_ISCOLORSPACE_MATRIX_BT2020_NCL(cspace) (SDL_COLORSPACEMATRIX(cspace) == SDL_MATRIX_COEFFICIENTS_BT2020_NCL)
968
969/**
970 * A macro to determine if an SDL_Colorspace has a limited range.
971 *
972 * \param cspace an SDL_Colorspace to check.
973 * \returns true if limited range, false otherwise.
974 *
975 * \threadsafety It is safe to call this macro from any thread.
976 *
977 * \since This macro is available since SDL 3.1.3.
978 */
979#define SDL_ISCOLORSPACE_LIMITED_RANGE(cspace) (SDL_COLORSPACERANGE(cspace) != SDL_COLOR_RANGE_FULL)
980
981/**
982 * A macro to determine if an SDL_Colorspace has a full range.
983 *
984 * \param cspace an SDL_Colorspace to check.
985 * \returns true if full range, false otherwise.
986 *
987 * \threadsafety It is safe to call this macro from any thread.
988 *
989 * \since This macro is available since SDL 3.1.3.
990 */
991#define SDL_ISCOLORSPACE_FULL_RANGE(cspace) (SDL_COLORSPACERANGE(cspace) == SDL_COLOR_RANGE_FULL)
992
993/**
994 * Colorspace definitions.
995 *
996 * Since similar colorspaces may vary in their details (matrix, transfer
997 * function, etc.), this is not an exhaustive list, but rather a
998 * representative sample of the kinds of colorspaces supported in SDL.
999 *
1000 * \since This enum is available since SDL 3.1.3.
1001 *
1002 * \sa SDL_ColorPrimaries
1003 * \sa SDL_ColorRange
1004 * \sa SDL_ColorType
1005 * \sa SDL_MatrixCoefficients
1006 * \sa SDL_TransferCharacteristics
1007 */
1008typedef enum SDL_Colorspace
1009{
1011
1012 /* sRGB is a gamma corrected colorspace, and the default colorspace for SDL rendering and 8-bit RGB surfaces */
1013 SDL_COLORSPACE_SRGB = 0x120005a0u, /**< Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709 */
1014 /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_RGB,
1015 SDL_COLOR_RANGE_FULL,
1016 SDL_COLOR_PRIMARIES_BT709,
1017 SDL_TRANSFER_CHARACTERISTICS_SRGB,
1018 SDL_MATRIX_COEFFICIENTS_IDENTITY,
1019 SDL_CHROMA_LOCATION_NONE), */
1020
1021 /* This is a linear colorspace and the default colorspace for floating point surfaces. On Windows this is the scRGB colorspace, and on Apple platforms this is kCGColorSpaceExtendedLinearSRGB for EDR content */
1022 SDL_COLORSPACE_SRGB_LINEAR = 0x12000500u, /**< Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G10_NONE_P709 */
1023 /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_RGB,
1024 SDL_COLOR_RANGE_FULL,
1025 SDL_COLOR_PRIMARIES_BT709,
1026 SDL_TRANSFER_CHARACTERISTICS_LINEAR,
1027 SDL_MATRIX_COEFFICIENTS_IDENTITY,
1028 SDL_CHROMA_LOCATION_NONE), */
1029
1030 /* HDR10 is a non-linear HDR colorspace and the default colorspace for 10-bit surfaces */
1031 SDL_COLORSPACE_HDR10 = 0x12002600u, /**< Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020 */
1032 /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_RGB,
1033 SDL_COLOR_RANGE_FULL,
1034 SDL_COLOR_PRIMARIES_BT2020,
1035 SDL_TRANSFER_CHARACTERISTICS_PQ,
1036 SDL_MATRIX_COEFFICIENTS_IDENTITY,
1037 SDL_CHROMA_LOCATION_NONE), */
1038
1039 SDL_COLORSPACE_JPEG = 0x220004c6u, /**< Equivalent to DXGI_COLOR_SPACE_YCBCR_FULL_G22_NONE_P709_X601 */
1040 /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_YCBCR,
1041 SDL_COLOR_RANGE_FULL,
1042 SDL_COLOR_PRIMARIES_BT709,
1043 SDL_TRANSFER_CHARACTERISTICS_BT601,
1044 SDL_MATRIX_COEFFICIENTS_BT601,
1045 SDL_CHROMA_LOCATION_NONE), */
1046
1047 SDL_COLORSPACE_BT601_LIMITED = 0x211018c6u, /**< Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601 */
1048 /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_YCBCR,
1049 SDL_COLOR_RANGE_LIMITED,
1050 SDL_COLOR_PRIMARIES_BT601,
1051 SDL_TRANSFER_CHARACTERISTICS_BT601,
1052 SDL_MATRIX_COEFFICIENTS_BT601,
1053 SDL_CHROMA_LOCATION_LEFT), */
1054
1055 SDL_COLORSPACE_BT601_FULL = 0x221018c6u, /**< Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601 */
1056 /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_YCBCR,
1057 SDL_COLOR_RANGE_FULL,
1058 SDL_COLOR_PRIMARIES_BT601,
1059 SDL_TRANSFER_CHARACTERISTICS_BT601,
1060 SDL_MATRIX_COEFFICIENTS_BT601,
1061 SDL_CHROMA_LOCATION_LEFT), */
1062
1063 SDL_COLORSPACE_BT709_LIMITED = 0x21100421u, /**< Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709 */
1064 /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_YCBCR,
1065 SDL_COLOR_RANGE_LIMITED,
1066 SDL_COLOR_PRIMARIES_BT709,
1067 SDL_TRANSFER_CHARACTERISTICS_BT709,
1068 SDL_MATRIX_COEFFICIENTS_BT709,
1069 SDL_CHROMA_LOCATION_LEFT), */
1070
1071 SDL_COLORSPACE_BT709_FULL = 0x22100421u, /**< Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709 */
1072 /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_YCBCR,
1073 SDL_COLOR_RANGE_FULL,
1074 SDL_COLOR_PRIMARIES_BT709,
1075 SDL_TRANSFER_CHARACTERISTICS_BT709,
1076 SDL_MATRIX_COEFFICIENTS_BT709,
1077 SDL_CHROMA_LOCATION_LEFT), */
1078
1079 SDL_COLORSPACE_BT2020_LIMITED = 0x21102609u, /**< Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P2020 */
1080 /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_YCBCR,
1081 SDL_COLOR_RANGE_LIMITED,
1082 SDL_COLOR_PRIMARIES_BT2020,
1083 SDL_TRANSFER_CHARACTERISTICS_PQ,
1084 SDL_MATRIX_COEFFICIENTS_BT2020_NCL,
1085 SDL_CHROMA_LOCATION_LEFT), */
1086
1087 SDL_COLORSPACE_BT2020_FULL = 0x22102609u, /**< Equivalent to DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P2020 */
1088 /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_YCBCR,
1089 SDL_COLOR_RANGE_FULL,
1090 SDL_COLOR_PRIMARIES_BT2020,
1091 SDL_TRANSFER_CHARACTERISTICS_PQ,
1092 SDL_MATRIX_COEFFICIENTS_BT2020_NCL,
1093 SDL_CHROMA_LOCATION_LEFT), */
1094
1095 SDL_COLORSPACE_RGB_DEFAULT = SDL_COLORSPACE_SRGB, /**< The default colorspace for RGB surfaces if no colorspace is specified */
1096 SDL_COLORSPACE_YUV_DEFAULT = SDL_COLORSPACE_JPEG /**< The default colorspace for YUV surfaces if no colorspace is specified */
1098
1099/**
1100 * A structure that represents a color as RGBA components.
1101 *
1102 * The bits of this structure can be directly reinterpreted as an
1103 * integer-packed color which uses the SDL_PIXELFORMAT_RGBA32 format
1104 * (SDL_PIXELFORMAT_ABGR8888 on little-endian systems and
1105 * SDL_PIXELFORMAT_RGBA8888 on big-endian systems).
1106 *
1107 * \since This struct is available since SDL 3.1.3.
1108 */
1116
1117/**
1118 * The bits of this structure can be directly reinterpreted as a float-packed
1119 * color which uses the SDL_PIXELFORMAT_RGBA128_FLOAT format
1120 *
1121 * \since This struct is available since SDL 3.1.3.
1122 */
1123typedef struct SDL_FColor
1124{
1125 float r;
1126 float g;
1127 float b;
1128 float a;
1129} SDL_FColor;
1130
1131/**
1132 * A set of indexed colors representing a palette.
1133 *
1134 * \since This struct is available since SDL 3.1.3.
1135 *
1136 * \sa SDL_SetPaletteColors
1137 */
1138typedef struct SDL_Palette
1139{
1140 int ncolors; /**< number of elements in `colors`. */
1141 SDL_Color *colors; /**< an array of colors, `ncolors` long. */
1142 Uint32 version; /**< internal use only, do not touch. */
1143 int refcount; /**< internal use only, do not touch. */
1144} SDL_Palette;
1145
1146/**
1147 * Details about the format of a pixel.
1148 *
1149 * \since This struct is available since SDL 3.1.3.
1150 */
1170
1171/**
1172 * Get the human readable name of a pixel format.
1173 *
1174 * \param format the pixel format to query.
1175 * \returns the human readable name of the specified pixel format or
1176 * "SDL_PIXELFORMAT_UNKNOWN" if the format isn't recognized.
1177 *
1178 * \threadsafety It is safe to call this function from any thread.
1179 *
1180 * \since This function is available since SDL 3.1.3.
1181 */
1182extern SDL_DECLSPEC const char * SDLCALL SDL_GetPixelFormatName(SDL_PixelFormat format);
1183
1184/**
1185 * Convert one of the enumerated pixel formats to a bpp value and RGBA masks.
1186 *
1187 * \param format one of the SDL_PixelFormat values.
1188 * \param bpp a bits per pixel value; usually 15, 16, or 32.
1189 * \param Rmask a pointer filled in with the red mask for the format.
1190 * \param Gmask a pointer filled in with the green mask for the format.
1191 * \param Bmask a pointer filled in with the blue mask for the format.
1192 * \param Amask a pointer filled in with the alpha mask for the format.
1193 * \returns true on success or false on failure; call SDL_GetError() for more
1194 * information.
1195 *
1196 * \threadsafety It is safe to call this function from any thread.
1197 *
1198 * \since This function is available since SDL 3.1.3.
1199 *
1200 * \sa SDL_GetPixelFormatForMasks
1201 */
1202extern SDL_DECLSPEC bool SDLCALL SDL_GetMasksForPixelFormat(SDL_PixelFormat format, int *bpp, Uint32 *Rmask, Uint32 *Gmask, Uint32 *Bmask, Uint32 *Amask);
1203
1204/**
1205 * Convert a bpp value and RGBA masks to an enumerated pixel format.
1206 *
1207 * This will return `SDL_PIXELFORMAT_UNKNOWN` if the conversion wasn't
1208 * possible.
1209 *
1210 * \param bpp a bits per pixel value; usually 15, 16, or 32.
1211 * \param Rmask the red mask for the format.
1212 * \param Gmask the green mask for the format.
1213 * \param Bmask the blue mask for the format.
1214 * \param Amask the alpha mask for the format.
1215 * \returns the SDL_PixelFormat value corresponding to the format masks, or
1216 * SDL_PIXELFORMAT_UNKNOWN if there isn't a match.
1217 *
1218 * \threadsafety It is safe to call this function from any thread.
1219 *
1220 * \since This function is available since SDL 3.1.3.
1221 *
1222 * \sa SDL_GetMasksForPixelFormat
1223 */
1224extern SDL_DECLSPEC SDL_PixelFormat SDLCALL SDL_GetPixelFormatForMasks(int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
1225
1226/**
1227 * Create an SDL_PixelFormatDetails structure corresponding to a pixel format.
1228 *
1229 * Returned structure may come from a shared global cache (i.e. not newly
1230 * allocated), and hence should not be modified, especially the palette. Weird
1231 * errors such as `Blit combination not supported` may occur.
1232 *
1233 * \param format one of the SDL_PixelFormat values.
1234 * \returns a pointer to a SDL_PixelFormatDetails structure or NULL on
1235 * failure; call SDL_GetError() for more information.
1236 *
1237 * \threadsafety It is safe to call this function from any thread.
1238 *
1239 * \since This function is available since SDL 3.1.3.
1240 */
1241extern SDL_DECLSPEC const SDL_PixelFormatDetails * SDLCALL SDL_GetPixelFormatDetails(SDL_PixelFormat format);
1242
1243/**
1244 * Create a palette structure with the specified number of color entries.
1245 *
1246 * The palette entries are initialized to white.
1247 *
1248 * \param ncolors represents the number of color entries in the color palette.
1249 * \returns a new SDL_Palette structure on success or NULL on failure (e.g. if
1250 * there wasn't enough memory); call SDL_GetError() for more
1251 * information.
1252 *
1253 * \threadsafety It is safe to call this function from any thread.
1254 *
1255 * \since This function is available since SDL 3.1.3.
1256 *
1257 * \sa SDL_DestroyPalette
1258 * \sa SDL_SetPaletteColors
1259 * \sa SDL_SetSurfacePalette
1260 */
1261extern SDL_DECLSPEC SDL_Palette * SDLCALL SDL_CreatePalette(int ncolors);
1262
1263/**
1264 * Set a range of colors in a palette.
1265 *
1266 * \param palette the SDL_Palette structure to modify.
1267 * \param colors an array of SDL_Color structures to copy into the palette.
1268 * \param firstcolor the index of the first palette entry to modify.
1269 * \param ncolors the number of entries to modify.
1270 * \returns true on success or false on failure; call SDL_GetError() for more
1271 * information.
1272 *
1273 * \threadsafety It is safe to call this function from any thread, as long as
1274 * the palette is not modified or destroyed in another thread.
1275 *
1276 * \since This function is available since SDL 3.1.3.
1277 */
1278extern SDL_DECLSPEC bool SDLCALL SDL_SetPaletteColors(SDL_Palette *palette, const SDL_Color *colors, int firstcolor, int ncolors);
1279
1280/**
1281 * Free a palette created with SDL_CreatePalette().
1282 *
1283 * \param palette the SDL_Palette structure to be freed.
1284 *
1285 * \threadsafety It is safe to call this function from any thread, as long as
1286 * the palette is not modified or destroyed in another thread.
1287 *
1288 * \since This function is available since SDL 3.1.3.
1289 *
1290 * \sa SDL_CreatePalette
1291 */
1292extern SDL_DECLSPEC void SDLCALL SDL_DestroyPalette(SDL_Palette *palette);
1293
1294/**
1295 * Map an RGB triple to an opaque pixel value for a given pixel format.
1296 *
1297 * This function maps the RGB color value to the specified pixel format and
1298 * returns the pixel value best approximating the given RGB color value for
1299 * the given pixel format.
1300 *
1301 * If the format has a palette (8-bit) the index of the closest matching color
1302 * in the palette will be returned.
1303 *
1304 * If the specified pixel format has an alpha component it will be returned as
1305 * all 1 bits (fully opaque).
1306 *
1307 * If the pixel format bpp (color depth) is less than 32-bpp then the unused
1308 * upper bits of the return value can safely be ignored (e.g., with a 16-bpp
1309 * format the return value can be assigned to a Uint16, and similarly a Uint8
1310 * for an 8-bpp format).
1311 *
1312 * \param format a pointer to SDL_PixelFormatDetails describing the pixel
1313 * format.
1314 * \param palette an optional palette for indexed formats, may be NULL.
1315 * \param r the red component of the pixel in the range 0-255.
1316 * \param g the green component of the pixel in the range 0-255.
1317 * \param b the blue component of the pixel in the range 0-255.
1318 * \returns a pixel value.
1319 *
1320 * \threadsafety It is safe to call this function from any thread, as long as
1321 * the palette is not modified.
1322 *
1323 * \since This function is available since SDL 3.1.3.
1324 *
1325 * \sa SDL_GetPixelFormatDetails
1326 * \sa SDL_GetRGB
1327 * \sa SDL_MapRGBA
1328 * \sa SDL_MapSurfaceRGB
1329 */
1330extern SDL_DECLSPEC Uint32 SDLCALL SDL_MapRGB(const SDL_PixelFormatDetails *format, const SDL_Palette *palette, Uint8 r, Uint8 g, Uint8 b);
1331
1332/**
1333 * Map an RGBA quadruple to a pixel value for a given pixel format.
1334 *
1335 * This function maps the RGBA color value to the specified pixel format and
1336 * returns the pixel value best approximating the given RGBA color value for
1337 * the given pixel format.
1338 *
1339 * If the specified pixel format has no alpha component the alpha value will
1340 * be ignored (as it will be in formats with a palette).
1341 *
1342 * If the format has a palette (8-bit) the index of the closest matching color
1343 * in the palette will be returned.
1344 *
1345 * If the pixel format bpp (color depth) is less than 32-bpp then the unused
1346 * upper bits of the return value can safely be ignored (e.g., with a 16-bpp
1347 * format the return value can be assigned to a Uint16, and similarly a Uint8
1348 * for an 8-bpp format).
1349 *
1350 * \param format a pointer to SDL_PixelFormatDetails describing the pixel
1351 * format.
1352 * \param palette an optional palette for indexed formats, may be NULL.
1353 * \param r the red component of the pixel in the range 0-255.
1354 * \param g the green component of the pixel in the range 0-255.
1355 * \param b the blue component of the pixel in the range 0-255.
1356 * \param a the alpha component of the pixel in the range 0-255.
1357 * \returns a pixel value.
1358 *
1359 * \threadsafety It is safe to call this function from any thread, as long as
1360 * the palette is not modified.
1361 *
1362 * \since This function is available since SDL 3.1.3.
1363 *
1364 * \sa SDL_GetPixelFormatDetails
1365 * \sa SDL_GetRGBA
1366 * \sa SDL_MapRGB
1367 * \sa SDL_MapSurfaceRGBA
1368 */
1369extern SDL_DECLSPEC Uint32 SDLCALL SDL_MapRGBA(const SDL_PixelFormatDetails *format, const SDL_Palette *palette, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
1370
1371/**
1372 * Get RGB values from a pixel in the specified format.
1373 *
1374 * This function uses the entire 8-bit [0..255] range when converting color
1375 * components from pixel formats with less than 8-bits per RGB component
1376 * (e.g., a completely white pixel in 16-bit RGB565 format would return [0xff,
1377 * 0xff, 0xff] not [0xf8, 0xfc, 0xf8]).
1378 *
1379 * \param pixel a pixel value.
1380 * \param format a pointer to SDL_PixelFormatDetails describing the pixel
1381 * format.
1382 * \param palette an optional palette for indexed formats, may be NULL.
1383 * \param r a pointer filled in with the red component, may be NULL.
1384 * \param g a pointer filled in with the green component, may be NULL.
1385 * \param b a pointer filled in with the blue component, may be NULL.
1386 *
1387 * \threadsafety It is safe to call this function from any thread, as long as
1388 * the palette is not modified.
1389 *
1390 * \since This function is available since SDL 3.1.3.
1391 *
1392 * \sa SDL_GetPixelFormatDetails
1393 * \sa SDL_GetRGBA
1394 * \sa SDL_MapRGB
1395 * \sa SDL_MapRGBA
1396 */
1397extern SDL_DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixel, const SDL_PixelFormatDetails *format, const SDL_Palette *palette, Uint8 *r, Uint8 *g, Uint8 *b);
1398
1399/**
1400 * Get RGBA values from a pixel in the specified format.
1401 *
1402 * This function uses the entire 8-bit [0..255] range when converting color
1403 * components from pixel formats with less than 8-bits per RGB component
1404 * (e.g., a completely white pixel in 16-bit RGB565 format would return [0xff,
1405 * 0xff, 0xff] not [0xf8, 0xfc, 0xf8]).
1406 *
1407 * If the surface has no alpha component, the alpha will be returned as 0xff
1408 * (100% opaque).
1409 *
1410 * \param pixel a pixel value.
1411 * \param format a pointer to SDL_PixelFormatDetails describing the pixel
1412 * format.
1413 * \param palette an optional palette for indexed formats, may be NULL.
1414 * \param r a pointer filled in with the red component, may be NULL.
1415 * \param g a pointer filled in with the green component, may be NULL.
1416 * \param b a pointer filled in with the blue component, may be NULL.
1417 * \param a a pointer filled in with the alpha component, may be NULL.
1418 *
1419 * \threadsafety It is safe to call this function from any thread, as long as
1420 * the palette is not modified.
1421 *
1422 * \since This function is available since SDL 3.1.3.
1423 *
1424 * \sa SDL_GetPixelFormatDetails
1425 * \sa SDL_GetRGB
1426 * \sa SDL_MapRGB
1427 * \sa SDL_MapRGBA
1428 */
1429extern SDL_DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel, const SDL_PixelFormatDetails *format, const SDL_Palette *palette, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a);
1430
1431
1432/* Ends C function definitions when using C++ */
1433#ifdef __cplusplus
1434}
1435#endif
1436#include <SDL3/SDL_close_code.h>
1437
1438#endif /* SDL_pixels_h_ */
SDL_MatrixCoefficients
Definition SDL_pixels.h:788
@ SDL_MATRIX_COEFFICIENTS_BT709
Definition SDL_pixels.h:790
@ SDL_MATRIX_COEFFICIENTS_BT2020_CL
Definition SDL_pixels.h:798
@ SDL_MATRIX_COEFFICIENTS_BT601
Definition SDL_pixels.h:794
@ SDL_MATRIX_COEFFICIENTS_BT2020_NCL
Definition SDL_pixels.h:797
@ SDL_MATRIX_COEFFICIENTS_SMPTE240
Definition SDL_pixels.h:795
@ SDL_MATRIX_COEFFICIENTS_YCGCO
Definition SDL_pixels.h:796
@ SDL_MATRIX_COEFFICIENTS_CHROMA_DERIVED_NCL
Definition SDL_pixels.h:800
@ SDL_MATRIX_COEFFICIENTS_CHROMA_DERIVED_CL
Definition SDL_pixels.h:801
@ SDL_MATRIX_COEFFICIENTS_UNSPECIFIED
Definition SDL_pixels.h:791
@ SDL_MATRIX_COEFFICIENTS_CUSTOM
Definition SDL_pixels.h:803
@ SDL_MATRIX_COEFFICIENTS_ICTCP
Definition SDL_pixels.h:802
@ SDL_MATRIX_COEFFICIENTS_IDENTITY
Definition SDL_pixels.h:789
@ SDL_MATRIX_COEFFICIENTS_FCC
Definition SDL_pixels.h:792
@ SDL_MATRIX_COEFFICIENTS_BT470BG
Definition SDL_pixels.h:793
@ SDL_MATRIX_COEFFICIENTS_SMPTE2085
Definition SDL_pixels.h:799
SDL_PixelType
Definition SDL_pixels.h:135
@ SDL_PIXELTYPE_UNKNOWN
Definition SDL_pixels.h:136
@ SDL_PIXELTYPE_ARRAYU16
Definition SDL_pixels.h:144
@ SDL_PIXELTYPE_PACKED32
Definition SDL_pixels.h:142
@ SDL_PIXELTYPE_INDEX2
Definition SDL_pixels.h:149
@ SDL_PIXELTYPE_ARRAYU8
Definition SDL_pixels.h:143
@ SDL_PIXELTYPE_INDEX4
Definition SDL_pixels.h:138
@ SDL_PIXELTYPE_PACKED8
Definition SDL_pixels.h:140
@ SDL_PIXELTYPE_ARRAYF16
Definition SDL_pixels.h:146
@ SDL_PIXELTYPE_ARRAYU32
Definition SDL_pixels.h:145
@ SDL_PIXELTYPE_INDEX1
Definition SDL_pixels.h:137
@ SDL_PIXELTYPE_ARRAYF32
Definition SDL_pixels.h:147
@ SDL_PIXELTYPE_INDEX8
Definition SDL_pixels.h:139
@ SDL_PIXELTYPE_PACKED16
Definition SDL_pixels.h:141
SDL_ColorRange
Definition SDL_pixels.h:720
@ SDL_COLOR_RANGE_LIMITED
Definition SDL_pixels.h:722
@ SDL_COLOR_RANGE_FULL
Definition SDL_pixels.h:723
@ SDL_COLOR_RANGE_UNKNOWN
Definition SDL_pixels.h:721
SDL_ColorPrimaries
Definition SDL_pixels.h:733
@ SDL_COLOR_PRIMARIES_SMPTE431
Definition SDL_pixels.h:744
@ SDL_COLOR_PRIMARIES_CUSTOM
Definition SDL_pixels.h:747
@ SDL_COLOR_PRIMARIES_EBU3213
Definition SDL_pixels.h:746
@ SDL_COLOR_PRIMARIES_GENERIC_FILM
Definition SDL_pixels.h:741
@ SDL_COLOR_PRIMARIES_BT601
Definition SDL_pixels.h:739
@ SDL_COLOR_PRIMARIES_UNSPECIFIED
Definition SDL_pixels.h:736
@ SDL_COLOR_PRIMARIES_SMPTE240
Definition SDL_pixels.h:740
@ SDL_COLOR_PRIMARIES_XYZ
Definition SDL_pixels.h:743
@ SDL_COLOR_PRIMARIES_UNKNOWN
Definition SDL_pixels.h:734
@ SDL_COLOR_PRIMARIES_SMPTE432
Definition SDL_pixels.h:745
@ SDL_COLOR_PRIMARIES_BT2020
Definition SDL_pixels.h:742
@ SDL_COLOR_PRIMARIES_BT470BG
Definition SDL_pixels.h:738
@ SDL_COLOR_PRIMARIES_BT709
Definition SDL_pixels.h:735
@ SDL_COLOR_PRIMARIES_BT470M
Definition SDL_pixels.h:737
Uint32 SDL_MapRGB(const SDL_PixelFormatDetails *format, const SDL_Palette *palette, Uint8 r, Uint8 g, Uint8 b)
SDL_PackedLayout
Definition SDL_pixels.h:204
@ SDL_PACKEDLAYOUT_NONE
Definition SDL_pixels.h:205
@ SDL_PACKEDLAYOUT_8888
Definition SDL_pixels.h:211
@ SDL_PACKEDLAYOUT_1010102
Definition SDL_pixels.h:213
@ SDL_PACKEDLAYOUT_565
Definition SDL_pixels.h:210
@ SDL_PACKEDLAYOUT_332
Definition SDL_pixels.h:206
@ SDL_PACKEDLAYOUT_5551
Definition SDL_pixels.h:209
@ SDL_PACKEDLAYOUT_1555
Definition SDL_pixels.h:208
@ SDL_PACKEDLAYOUT_4444
Definition SDL_pixels.h:207
@ SDL_PACKEDLAYOUT_2101010
Definition SDL_pixels.h:212
SDL_Palette * SDL_CreatePalette(int ncolors)
SDL_BitmapOrder
Definition SDL_pixels.h:158
@ SDL_BITMAPORDER_1234
Definition SDL_pixels.h:161
@ SDL_BITMAPORDER_NONE
Definition SDL_pixels.h:159
@ SDL_BITMAPORDER_4321
Definition SDL_pixels.h:160
SDL_ChromaLocation
Definition SDL_pixels.h:812
@ SDL_CHROMA_LOCATION_NONE
Definition SDL_pixels.h:813
@ SDL_CHROMA_LOCATION_TOPLEFT
Definition SDL_pixels.h:816
@ SDL_CHROMA_LOCATION_CENTER
Definition SDL_pixels.h:815
@ SDL_CHROMA_LOCATION_LEFT
Definition SDL_pixels.h:814
Uint32 SDL_MapRGBA(const SDL_PixelFormatDetails *format, const SDL_Palette *palette, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
void SDL_DestroyPalette(SDL_Palette *palette)
SDL_ColorType
Definition SDL_pixels.h:707
@ SDL_COLOR_TYPE_RGB
Definition SDL_pixels.h:709
@ SDL_COLOR_TYPE_YCBCR
Definition SDL_pixels.h:710
@ SDL_COLOR_TYPE_UNKNOWN
Definition SDL_pixels.h:708
SDL_TransferCharacteristics
Definition SDL_pixels.h:758
@ SDL_TRANSFER_CHARACTERISTICS_BT709
Definition SDL_pixels.h:760
@ SDL_TRANSFER_CHARACTERISTICS_BT1361
Definition SDL_pixels.h:770
@ SDL_TRANSFER_CHARACTERISTICS_CUSTOM
Definition SDL_pixels.h:777
@ SDL_TRANSFER_CHARACTERISTICS_HLG
Definition SDL_pixels.h:776
@ SDL_TRANSFER_CHARACTERISTICS_LOG100_SQRT10
Definition SDL_pixels.h:768
@ SDL_TRANSFER_CHARACTERISTICS_UNKNOWN
Definition SDL_pixels.h:759
@ SDL_TRANSFER_CHARACTERISTICS_BT601
Definition SDL_pixels.h:764
@ SDL_TRANSFER_CHARACTERISTICS_IEC61966
Definition SDL_pixels.h:769
@ SDL_TRANSFER_CHARACTERISTICS_UNSPECIFIED
Definition SDL_pixels.h:761
@ SDL_TRANSFER_CHARACTERISTICS_SMPTE428
Definition SDL_pixels.h:775
@ SDL_TRANSFER_CHARACTERISTICS_LOG100
Definition SDL_pixels.h:767
@ SDL_TRANSFER_CHARACTERISTICS_GAMMA28
Definition SDL_pixels.h:763
@ SDL_TRANSFER_CHARACTERISTICS_SMPTE240
Definition SDL_pixels.h:765
@ SDL_TRANSFER_CHARACTERISTICS_BT2020_10BIT
Definition SDL_pixels.h:772
@ SDL_TRANSFER_CHARACTERISTICS_SRGB
Definition SDL_pixels.h:771
@ SDL_TRANSFER_CHARACTERISTICS_PQ
Definition SDL_pixels.h:774
@ SDL_TRANSFER_CHARACTERISTICS_LINEAR
Definition SDL_pixels.h:766
@ SDL_TRANSFER_CHARACTERISTICS_BT2020_12BIT
Definition SDL_pixels.h:773
@ SDL_TRANSFER_CHARACTERISTICS_GAMMA22
Definition SDL_pixels.h:762
SDL_ArrayOrder
Definition SDL_pixels.h:188
@ SDL_ARRAYORDER_RGB
Definition SDL_pixels.h:190
@ SDL_ARRAYORDER_NONE
Definition SDL_pixels.h:189
@ SDL_ARRAYORDER_ARGB
Definition SDL_pixels.h:192
@ SDL_ARRAYORDER_BGRA
Definition SDL_pixels.h:194
@ SDL_ARRAYORDER_ABGR
Definition SDL_pixels.h:195
@ SDL_ARRAYORDER_RGBA
Definition SDL_pixels.h:191
@ SDL_ARRAYORDER_BGR
Definition SDL_pixels.h:193
bool SDL_GetMasksForPixelFormat(SDL_PixelFormat format, int *bpp, Uint32 *Rmask, Uint32 *Gmask, Uint32 *Bmask, Uint32 *Amask)
const char * SDL_GetPixelFormatName(SDL_PixelFormat format)
SDL_Colorspace
@ SDL_COLORSPACE_BT2020_LIMITED
@ SDL_COLORSPACE_BT601_LIMITED
@ SDL_COLORSPACE_BT709_FULL
@ SDL_COLORSPACE_HDR10
@ SDL_COLORSPACE_BT601_FULL
@ SDL_COLORSPACE_UNKNOWN
@ SDL_COLORSPACE_BT2020_FULL
@ SDL_COLORSPACE_JPEG
@ SDL_COLORSPACE_BT709_LIMITED
@ SDL_COLORSPACE_SRGB_LINEAR
@ SDL_COLORSPACE_SRGB
@ SDL_COLORSPACE_RGB_DEFAULT
@ SDL_COLORSPACE_YUV_DEFAULT
SDL_PixelFormat
Definition SDL_pixels.h:549
@ SDL_PIXELFORMAT_BGR48_FLOAT
Definition SDL_pixels.h:637
@ SDL_PIXELFORMAT_RGBA128_FLOAT
Definition SDL_pixels.h:651
@ SDL_PIXELFORMAT_BGR565
Definition SDL_pixels.h:593
@ SDL_PIXELFORMAT_P010
Definition SDL_pixels.h:674
@ SDL_PIXELFORMAT_EXTERNAL_OES
Definition SDL_pixels.h:676
@ SDL_PIXELFORMAT_ARGB64
Definition SDL_pixels.h:629
@ SDL_PIXELFORMAT_YVYU
Definition SDL_pixels.h:668
@ SDL_PIXELFORMAT_RGB332
Definition SDL_pixels.h:565
@ SDL_PIXELFORMAT_INDEX2LSB
Definition SDL_pixels.h:555
@ SDL_PIXELFORMAT_INDEX1LSB
Definition SDL_pixels.h:551
@ SDL_PIXELFORMAT_RGB96_FLOAT
Definition SDL_pixels.h:647
@ SDL_PIXELFORMAT_RGBX32
Definition SDL_pixels.h:685
@ SDL_PIXELFORMAT_ABGR4444
Definition SDL_pixels.h:579
@ SDL_PIXELFORMAT_BGRA4444
Definition SDL_pixels.h:581
@ SDL_PIXELFORMAT_BGR24
Definition SDL_pixels.h:597
@ SDL_PIXELFORMAT_INDEX4MSB
Definition SDL_pixels.h:561
@ SDL_PIXELFORMAT_ABGR2101010
Definition SDL_pixels.h:621
@ SDL_PIXELFORMAT_BGRA32
Definition SDL_pixels.h:683
@ SDL_PIXELFORMAT_XBGR2101010
Definition SDL_pixels.h:617
@ SDL_PIXELFORMAT_RGBA64_FLOAT
Definition SDL_pixels.h:639
@ SDL_PIXELFORMAT_INDEX2MSB
Definition SDL_pixels.h:557
@ SDL_PIXELFORMAT_BGRA64_FLOAT
Definition SDL_pixels.h:643
@ SDL_PIXELFORMAT_RGBA8888
Definition SDL_pixels.h:609
@ SDL_PIXELFORMAT_RGBA5551
Definition SDL_pixels.h:585
@ SDL_PIXELFORMAT_ARGB1555
Definition SDL_pixels.h:583
@ SDL_PIXELFORMAT_XBGR4444
Definition SDL_pixels.h:569
@ SDL_PIXELFORMAT_RGBA64
Definition SDL_pixels.h:627
@ SDL_PIXELFORMAT_INDEX8
Definition SDL_pixels.h:563
@ SDL_PIXELFORMAT_XRGB2101010
Definition SDL_pixels.h:615
@ SDL_PIXELFORMAT_XRGB8888
Definition SDL_pixels.h:599
@ SDL_PIXELFORMAT_UYVY
Definition SDL_pixels.h:666
@ SDL_PIXELFORMAT_BGRX32
Definition SDL_pixels.h:687
@ SDL_PIXELFORMAT_YV12
Definition SDL_pixels.h:660
@ SDL_PIXELFORMAT_ABGR32
Definition SDL_pixels.h:684
@ SDL_PIXELFORMAT_BGRX8888
Definition SDL_pixels.h:605
@ SDL_PIXELFORMAT_RGB24
Definition SDL_pixels.h:595
@ SDL_PIXELFORMAT_BGRA64
Definition SDL_pixels.h:631
@ SDL_PIXELFORMAT_ABGR8888
Definition SDL_pixels.h:611
@ SDL_PIXELFORMAT_YUY2
Definition SDL_pixels.h:664
@ SDL_PIXELFORMAT_XBGR32
Definition SDL_pixels.h:688
@ SDL_PIXELFORMAT_NV12
Definition SDL_pixels.h:670
@ SDL_PIXELFORMAT_BGRA8888
Definition SDL_pixels.h:613
@ SDL_PIXELFORMAT_ABGR128_FLOAT
Definition SDL_pixels.h:657
@ SDL_PIXELFORMAT_ARGB32
Definition SDL_pixels.h:682
@ SDL_PIXELFORMAT_ABGR1555
Definition SDL_pixels.h:587
@ SDL_PIXELFORMAT_NV21
Definition SDL_pixels.h:672
@ SDL_PIXELFORMAT_IYUV
Definition SDL_pixels.h:662
@ SDL_PIXELFORMAT_ARGB8888
Definition SDL_pixels.h:607
@ SDL_PIXELFORMAT_ABGR64_FLOAT
Definition SDL_pixels.h:645
@ SDL_PIXELFORMAT_ABGR64
Definition SDL_pixels.h:633
@ SDL_PIXELFORMAT_XRGB32
Definition SDL_pixels.h:686
@ SDL_PIXELFORMAT_XBGR1555
Definition SDL_pixels.h:573
@ SDL_PIXELFORMAT_RGB48
Definition SDL_pixels.h:623
@ SDL_PIXELFORMAT_XRGB4444
Definition SDL_pixels.h:567
@ SDL_PIXELFORMAT_BGR96_FLOAT
Definition SDL_pixels.h:649
@ SDL_PIXELFORMAT_ARGB4444
Definition SDL_pixels.h:575
@ SDL_PIXELFORMAT_RGB48_FLOAT
Definition SDL_pixels.h:635
@ SDL_PIXELFORMAT_BGR48
Definition SDL_pixels.h:625
@ SDL_PIXELFORMAT_RGBA32
Definition SDL_pixels.h:681
@ SDL_PIXELFORMAT_BGRA128_FLOAT
Definition SDL_pixels.h:655
@ SDL_PIXELFORMAT_ARGB64_FLOAT
Definition SDL_pixels.h:641
@ SDL_PIXELFORMAT_INDEX1MSB
Definition SDL_pixels.h:553
@ SDL_PIXELFORMAT_INDEX4LSB
Definition SDL_pixels.h:559
@ SDL_PIXELFORMAT_RGBX8888
Definition SDL_pixels.h:601
@ SDL_PIXELFORMAT_BGRA5551
Definition SDL_pixels.h:589
@ SDL_PIXELFORMAT_ARGB128_FLOAT
Definition SDL_pixels.h:653
@ SDL_PIXELFORMAT_XRGB1555
Definition SDL_pixels.h:571
@ SDL_PIXELFORMAT_RGB565
Definition SDL_pixels.h:591
@ SDL_PIXELFORMAT_XBGR8888
Definition SDL_pixels.h:603
@ SDL_PIXELFORMAT_ARGB2101010
Definition SDL_pixels.h:619
@ SDL_PIXELFORMAT_UNKNOWN
Definition SDL_pixels.h:550
@ SDL_PIXELFORMAT_RGBA4444
Definition SDL_pixels.h:577
void SDL_GetRGB(Uint32 pixel, const SDL_PixelFormatDetails *format, const SDL_Palette *palette, Uint8 *r, Uint8 *g, Uint8 *b)
const SDL_PixelFormatDetails * SDL_GetPixelFormatDetails(SDL_PixelFormat format)
SDL_PackedOrder
Definition SDL_pixels.h:170
@ SDL_PACKEDORDER_NONE
Definition SDL_pixels.h:171
@ SDL_PACKEDORDER_RGBX
Definition SDL_pixels.h:173
@ SDL_PACKEDORDER_BGRX
Definition SDL_pixels.h:177
@ SDL_PACKEDORDER_XBGR
Definition SDL_pixels.h:176
@ SDL_PACKEDORDER_RGBA
Definition SDL_pixels.h:175
@ SDL_PACKEDORDER_ABGR
Definition SDL_pixels.h:178
@ SDL_PACKEDORDER_BGRA
Definition SDL_pixels.h:179
@ SDL_PACKEDORDER_XRGB
Definition SDL_pixels.h:172
@ SDL_PACKEDORDER_ARGB
Definition SDL_pixels.h:174
bool SDL_SetPaletteColors(SDL_Palette *palette, const SDL_Color *colors, int firstcolor, int ncolors)
SDL_PixelFormat SDL_GetPixelFormatForMasks(int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
void SDL_GetRGBA(Uint32 pixel, const SDL_PixelFormatDetails *format, const SDL_Palette *palette, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a)
uint8_t Uint8
Definition SDL_stdinc.h:399
uint32_t Uint32
Definition SDL_stdinc.h:435
Uint32 version
SDL_Color * colors
SDL_PixelFormat format