SDL 3.0
SDL_pixels.h
Go to the documentation of this file.
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2026 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.2.0.
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.2.0.
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.2.0.
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.2.0.
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.2.0.
133 */
151
152/**
153 * Bitmap pixel order, high bit -> low bit.
154 *
155 * \since This enum is available since SDL 3.2.0.
156 */
163
164/**
165 * Packed component order, high bit -> low bit.
166 *
167 * \since This enum is available since SDL 3.2.0.
168 */
181
182/**
183 * Array component order, low byte -> high byte.
184 *
185 * \since This enum is available since SDL 3.2.0.
186 */
197
198/**
199 * Packed component layout.
200 *
201 * \since This enum is available since SDL 3.2.0.
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.2.0.
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.2.0.
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.2.0.
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.2.0.
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.2.0.
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.2.0.
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.2.0.
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.2.0.
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) || \
367 ((format) == SDL_PIXELFORMAT_I0FL) || \
368 ((format) == SDL_PIXELFORMAT_I4FL)) ? 2 : 1) : (((format) >> 0) & 0xFF))
369
370
371/**
372 * A macro to determine if an SDL_PixelFormat is an indexed format.
373 *
374 * Note that this macro double-evaluates its parameter, so do not use
375 * expressions with side-effects here.
376 *
377 * \param format an SDL_PixelFormat to check.
378 * \returns true if the format is indexed, false otherwise.
379 *
380 * \threadsafety It is safe to call this macro from any thread.
381 *
382 * \since This macro is available since SDL 3.2.0.
383 */
384#define SDL_ISPIXELFORMAT_INDEXED(format) \
385 (!SDL_ISPIXELFORMAT_FOURCC(format) && \
386 ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX1) || \
387 (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX2) || \
388 (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX4) || \
389 (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX8)))
390
391/**
392 * A macro to determine if an SDL_PixelFormat is a packed format.
393 *
394 * Note that this macro double-evaluates its parameter, so do not use
395 * expressions with side-effects here.
396 *
397 * \param format an SDL_PixelFormat to check.
398 * \returns true if the format is packed, false otherwise.
399 *
400 * \threadsafety It is safe to call this macro from any thread.
401 *
402 * \since This macro is available since SDL 3.2.0.
403 */
404#define SDL_ISPIXELFORMAT_PACKED(format) \
405 (!SDL_ISPIXELFORMAT_FOURCC(format) && \
406 ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_PACKED8) || \
407 (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_PACKED16) || \
408 (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_PACKED32)))
409
410/**
411 * A macro to determine if an SDL_PixelFormat is an array format.
412 *
413 * Note that this macro double-evaluates its parameter, so do not use
414 * expressions with side-effects here.
415 *
416 * \param format an SDL_PixelFormat to check.
417 * \returns true if the format is an array, false otherwise.
418 *
419 * \threadsafety It is safe to call this macro from any thread.
420 *
421 * \since This macro is available since SDL 3.2.0.
422 */
423#define SDL_ISPIXELFORMAT_ARRAY(format) \
424 (!SDL_ISPIXELFORMAT_FOURCC(format) && \
425 ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYU8) || \
426 (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYU16) || \
427 (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYU32) || \
428 (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYF16) || \
429 (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYF32)))
430
431/**
432 * A macro to determine if an SDL_PixelFormat is a 10-bit format.
433 *
434 * Note that this macro double-evaluates its parameter, so do not use
435 * expressions with side-effects here.
436 *
437 * \param format an SDL_PixelFormat to check.
438 * \returns true if the format is 10-bit, false otherwise.
439 *
440 * \threadsafety It is safe to call this macro from any thread.
441 *
442 * \since This macro is available since SDL 3.2.0.
443 */
444#define SDL_ISPIXELFORMAT_10BIT(format) \
445 (!SDL_ISPIXELFORMAT_FOURCC(format) && \
446 ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_PACKED32) && \
447 (SDL_PIXELLAYOUT(format) == SDL_PACKEDLAYOUT_2101010)))
448
449/**
450 * A macro to determine if an SDL_PixelFormat is a floating point format.
451 *
452 * Note that this macro double-evaluates its parameter, so do not use
453 * expressions with side-effects here.
454 *
455 * \param format an SDL_PixelFormat to check.
456 * \returns true if the format is a floating point, false otherwise.
457 *
458 * \threadsafety It is safe to call this macro from any thread.
459 *
460 * \since This macro is available since SDL 3.2.0.
461 */
462#define SDL_ISPIXELFORMAT_FLOAT(format) \
463 (!SDL_ISPIXELFORMAT_FOURCC(format) && \
464 ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYF16) || \
465 (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYF32)))
466
467/**
468 * A macro to determine if an SDL_PixelFormat has an alpha channel.
469 *
470 * Note that this macro double-evaluates its parameter, so do not use
471 * expressions with side-effects here.
472 *
473 * \param format an SDL_PixelFormat to check.
474 * \returns true if the format has alpha, false otherwise.
475 *
476 * \threadsafety It is safe to call this macro from any thread.
477 *
478 * \since This macro is available since SDL 3.2.0.
479 */
480#define SDL_ISPIXELFORMAT_ALPHA(format) \
481 ((SDL_ISPIXELFORMAT_PACKED(format) && \
482 ((SDL_PIXELORDER(format) == SDL_PACKEDORDER_ARGB) || \
483 (SDL_PIXELORDER(format) == SDL_PACKEDORDER_RGBA) || \
484 (SDL_PIXELORDER(format) == SDL_PACKEDORDER_ABGR) || \
485 (SDL_PIXELORDER(format) == SDL_PACKEDORDER_BGRA))) || \
486 (SDL_ISPIXELFORMAT_ARRAY(format) && \
487 ((SDL_PIXELORDER(format) == SDL_ARRAYORDER_ARGB) || \
488 (SDL_PIXELORDER(format) == SDL_ARRAYORDER_RGBA) || \
489 (SDL_PIXELORDER(format) == SDL_ARRAYORDER_ABGR) || \
490 (SDL_PIXELORDER(format) == SDL_ARRAYORDER_BGRA))))
491
492
493/**
494 * A macro to determine if an SDL_PixelFormat is a "FourCC" format.
495 *
496 * This covers custom and other unusual formats.
497 *
498 * Note that this macro double-evaluates its parameter, so do not use
499 * expressions with side-effects here.
500 *
501 * \param format an SDL_PixelFormat to check.
502 * \returns true if the format has alpha, false otherwise.
503 *
504 * \threadsafety It is safe to call this macro from any thread.
505 *
506 * \since This macro is available since SDL 3.2.0.
507 */
508#define SDL_ISPIXELFORMAT_FOURCC(format) /* The flag is set to 1 because 0x1? is not in the printable ASCII range */ \
509 ((format) && (SDL_PIXELFLAG(format) != 1))
510
511/* Note: If you modify this enum, update SDL_GetPixelFormatName() */
512
513/**
514 * Pixel format.
515 *
516 * SDL's pixel formats have the following naming convention:
517 *
518 * - Names with a list of components and a single bit count, such as RGB24 and
519 * ABGR32, define a platform-independent encoding into bytes in the order
520 * specified. For example, in RGB24 data, each pixel is encoded in 3 bytes
521 * (red, green, blue) in that order, and in ABGR32 data, each pixel is
522 * encoded in 4 bytes (alpha, blue, green, red) in that order. Use these
523 * names if the property of a format that is important to you is the order
524 * of the bytes in memory or on disk.
525 * - Names with a bit count per component, such as ARGB8888 and XRGB1555, are
526 * "packed" into an appropriately-sized integer in the platform's native
527 * endianness. For example, ARGB8888 is a sequence of 32-bit integers; in
528 * each integer, the most significant bits are alpha, and the least
529 * significant bits are blue. On a little-endian CPU such as x86, the least
530 * significant bits of each integer are arranged first in memory, but on a
531 * big-endian CPU such as s390x, the most significant bits are arranged
532 * first. Use these names if the property of a format that is important to
533 * you is the meaning of each bit position within a native-endianness
534 * integer.
535 * - In indexed formats such as INDEX4LSB, each pixel is represented by
536 * encoding an index into the palette into the indicated number of bits,
537 * with multiple pixels packed into each byte if appropriate. In LSB
538 * formats, the first (leftmost) pixel is stored in the least-significant
539 * bits of the byte; in MSB formats, it's stored in the most-significant
540 * bits. INDEX8 does not need LSB/MSB variants, because each pixel exactly
541 * fills one byte.
542 *
543 * The 32-bit byte-array encodings such as RGBA32 are aliases for the
544 * appropriate 8888 encoding for the current platform. For example, RGBA32 is
545 * an alias for ABGR8888 on little-endian CPUs like x86, or an alias for
546 * RGBA8888 on big-endian CPUs.
547 *
548 * \since This enum is available since SDL 3.2.0.
549 */
550typedef enum SDL_PixelFormat
551{
554 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_4321, 0, 1, 0), */
556 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_1234, 0, 1, 0), */
558 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX2, SDL_BITMAPORDER_4321, 0, 2, 0), */
560 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX2, SDL_BITMAPORDER_1234, 0, 2, 0), */
562 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_4321, 0, 4, 0), */
564 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_1234, 0, 4, 0), */
566 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX8, 0, 0, 8, 1), */
568 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED8, SDL_PACKEDORDER_XRGB, SDL_PACKEDLAYOUT_332, 8, 1), */
570 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB, SDL_PACKEDLAYOUT_4444, 12, 2), */
572 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR, SDL_PACKEDLAYOUT_4444, 12, 2), */
574 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB, SDL_PACKEDLAYOUT_1555, 15, 2), */
576 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR, SDL_PACKEDLAYOUT_1555, 15, 2), */
578 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ARGB, SDL_PACKEDLAYOUT_4444, 16, 2), */
580 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_RGBA, SDL_PACKEDLAYOUT_4444, 16, 2), */
582 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ABGR, SDL_PACKEDLAYOUT_4444, 16, 2), */
584 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_BGRA, SDL_PACKEDLAYOUT_4444, 16, 2), */
586 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ARGB, SDL_PACKEDLAYOUT_1555, 16, 2), */
588 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_RGBA, SDL_PACKEDLAYOUT_5551, 16, 2), */
590 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ABGR, SDL_PACKEDLAYOUT_1555, 16, 2), */
592 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_BGRA, SDL_PACKEDLAYOUT_5551, 16, 2), */
594 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB, SDL_PACKEDLAYOUT_565, 16, 2), */
596 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR, SDL_PACKEDLAYOUT_565, 16, 2), */
598 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_RGB, 0, 24, 3), */
600 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_BGR, 0, 24, 3), */
602 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XRGB, SDL_PACKEDLAYOUT_8888, 24, 4), */
604 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBX, SDL_PACKEDLAYOUT_8888, 24, 4), */
606 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XBGR, SDL_PACKEDLAYOUT_8888, 24, 4), */
608 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_BGRX, SDL_PACKEDLAYOUT_8888, 24, 4), */
610 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ARGB, SDL_PACKEDLAYOUT_8888, 32, 4), */
612 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBA, SDL_PACKEDLAYOUT_8888, 32, 4), */
614 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ABGR, SDL_PACKEDLAYOUT_8888, 32, 4), */
616 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_BGRA, SDL_PACKEDLAYOUT_8888, 32, 4), */
618 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XRGB, SDL_PACKEDLAYOUT_2101010, 32, 4), */
620 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XBGR, SDL_PACKEDLAYOUT_2101010, 32, 4), */
622 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ARGB, SDL_PACKEDLAYOUT_2101010, 32, 4), */
624 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ABGR, SDL_PACKEDLAYOUT_2101010, 32, 4), */
626 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU16, SDL_ARRAYORDER_RGB, 0, 48, 6), */
628 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU16, SDL_ARRAYORDER_BGR, 0, 48, 6), */
630 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU16, SDL_ARRAYORDER_RGBA, 0, 64, 8), */
632 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU16, SDL_ARRAYORDER_ARGB, 0, 64, 8), */
634 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU16, SDL_ARRAYORDER_BGRA, 0, 64, 8), */
636 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU16, SDL_ARRAYORDER_ABGR, 0, 64, 8), */
638 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF16, SDL_ARRAYORDER_RGB, 0, 48, 6), */
640 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF16, SDL_ARRAYORDER_BGR, 0, 48, 6), */
642 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF16, SDL_ARRAYORDER_RGBA, 0, 64, 8), */
644 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF16, SDL_ARRAYORDER_ARGB, 0, 64, 8), */
646 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF16, SDL_ARRAYORDER_BGRA, 0, 64, 8), */
648 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF16, SDL_ARRAYORDER_ABGR, 0, 64, 8), */
650 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF32, SDL_ARRAYORDER_RGB, 0, 96, 12), */
652 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF32, SDL_ARRAYORDER_BGR, 0, 96, 12), */
654 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF32, SDL_ARRAYORDER_RGBA, 0, 128, 16), */
656 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF32, SDL_ARRAYORDER_ARGB, 0, 128, 16), */
658 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF32, SDL_ARRAYORDER_BGRA, 0, 128, 16), */
660 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF32, SDL_ARRAYORDER_ABGR, 0, 128, 16), */
661
662 SDL_PIXELFORMAT_YV12 = 0x32315659u, /**< YUV 4:2:0 8-bit planar mode: Y + V + U (3 planes) */
663 /* SDL_DEFINE_PIXELFOURCC('Y', 'V', '1', '2'), */
664 SDL_PIXELFORMAT_IYUV = 0x56555949u, /**< YUV 4:2:0 8-bit planar mode: Y + U + V (3 planes) */
665 /* SDL_DEFINE_PIXELFOURCC('I', 'Y', 'U', 'V'), */
666 SDL_PIXELFORMAT_YUY2 = 0x32595559u, /**< YUV 4:2:0 8-bit packed mode: Y0+U0+Y1+V0 (1 plane) */
667 /* SDL_DEFINE_PIXELFOURCC('Y', 'U', 'Y', '2'), */
668 SDL_PIXELFORMAT_UYVY = 0x59565955u, /**< YUV 4:2:0 8-bit packed mode: U0+Y0+V0+Y1 (1 plane) */
669 /* SDL_DEFINE_PIXELFOURCC('U', 'Y', 'V', 'Y'), */
670 SDL_PIXELFORMAT_YVYU = 0x55595659u, /**< YUV 4:2:0 8-bit packed mode: Y0+V0+Y1+U0 (1 plane) */
671 /* SDL_DEFINE_PIXELFOURCC('Y', 'V', 'Y', 'U'), */
672 SDL_PIXELFORMAT_NV12 = 0x3231564eu, /**< YUV 4:2:0 8-bit planar mode: Y + U/V interleaved (2 planes) */
673 /* SDL_DEFINE_PIXELFOURCC('N', 'V', '1', '2'), */
674 SDL_PIXELFORMAT_NV21 = 0x3132564eu, /**< YUV 4:2:0 8-bit planar mode: Y + V/U interleaved (2 planes) */
675 /* SDL_DEFINE_PIXELFOURCC('N', 'V', '2', '1'), */
676 SDL_PIXELFORMAT_I444 = 0x34343449u, /**< YUV 4:4:4 8-bit planar mode: Y + U + V (3 planes) */
677 /* SDL_DEFINE_PIXELFOURCC('I', '4', '4', '4'), */
678 SDL_PIXELFORMAT_P010 = 0x30313050u, /**< YUV 4:2:0 16-bit planar mode: Y + U/V interleaved (2 planes) */
679 /* SDL_DEFINE_PIXELFOURCC('P', '0', '1', '0'), */
680 SDL_PIXELFORMAT_I0FL = 0x4c463049u, /**< YUV 4:2:0 16-bit planar mode: Y + U + V (3 planes) */
681 /* SDL_DEFINE_PIXELFOURCC('I', '0', 'F', 'L'), */
682 SDL_PIXELFORMAT_I4FL = 0x4c463449u, /**< YUV 4:4:4 16-bit planar mode: Y + U + V (3 planes) */
683 /* SDL_DEFINE_PIXELFOURCC('I', '4', 'F', 'L'), */
684 SDL_PIXELFORMAT_EXTERNAL_OES = 0x2053454fu, /**< Android video texture format */
685 /* SDL_DEFINE_PIXELFOURCC('O', 'E', 'S', ' ') */
686
687 SDL_PIXELFORMAT_MJPG = 0x47504a4du, /**< Motion JPEG */
688 /* SDL_DEFINE_PIXELFOURCC('M', 'J', 'P', 'G') */
689
690 /* Aliases for RGBA byte arrays of color data, for the current platform */
691 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
700 #else
709 #endif
711
712/**
713 * Colorspace color type.
714 *
715 * \since This enum is available since SDL 3.2.0.
716 */
723
724/**
725 * Colorspace color range, as described by
726 * https://www.itu.int/rec/R-REC-BT.2100-2-201807-I/en
727 *
728 * \since This enum is available since SDL 3.2.0.
729 */
730typedef enum SDL_ColorRange
731{
733 SDL_COLOR_RANGE_LIMITED = 1, /**< Narrow range, e.g. 16-235 for 8-bit RGB and luma, and 16-240 for 8-bit chroma */
734 SDL_COLOR_RANGE_FULL = 2 /**< Full range, e.g. 0-255 for 8-bit RGB and luma, and 1-255 for 8-bit chroma */
736
737/**
738 * Colorspace color primaries, as described by
739 * https://www.itu.int/rec/T-REC-H.273-201612-S/en
740 *
741 * \since This enum is available since SDL 3.2.0.
742 */
744{
746 SDL_COLOR_PRIMARIES_BT709 = 1, /**< ITU-R BT.709-6 */
748 SDL_COLOR_PRIMARIES_BT470M = 4, /**< ITU-R BT.470-6 System M */
749 SDL_COLOR_PRIMARIES_BT470BG = 5, /**< ITU-R BT.470-6 System B, G / ITU-R BT.601-7 625 */
750 SDL_COLOR_PRIMARIES_BT601 = 6, /**< ITU-R BT.601-7 525, SMPTE 170M */
751 SDL_COLOR_PRIMARIES_SMPTE240 = 7, /**< SMPTE 240M, functionally the same as SDL_COLOR_PRIMARIES_BT601 */
752 SDL_COLOR_PRIMARIES_GENERIC_FILM = 8, /**< Generic film (color filters using Illuminant C) */
753 SDL_COLOR_PRIMARIES_BT2020 = 9, /**< ITU-R BT.2020-2 / ITU-R BT.2100-0 */
754 SDL_COLOR_PRIMARIES_XYZ = 10, /**< SMPTE ST 428-1 */
755 SDL_COLOR_PRIMARIES_SMPTE431 = 11, /**< SMPTE RP 431-2 */
756 SDL_COLOR_PRIMARIES_SMPTE432 = 12, /**< SMPTE EG 432-1 / DCI P3 */
757 SDL_COLOR_PRIMARIES_EBU3213 = 22, /**< EBU Tech. 3213-E */
760
761/**
762 * Colorspace transfer characteristics.
763 *
764 * These are as described by https://www.itu.int/rec/T-REC-H.273-201612-S/en
765 *
766 * \since This enum is available since SDL 3.2.0.
767 */
769{
771 SDL_TRANSFER_CHARACTERISTICS_BT709 = 1, /**< Rec. ITU-R BT.709-6 / ITU-R BT1361 */
773 SDL_TRANSFER_CHARACTERISTICS_GAMMA22 = 4, /**< ITU-R BT.470-6 System M / ITU-R BT1700 625 PAL & SECAM */
774 SDL_TRANSFER_CHARACTERISTICS_GAMMA28 = 5, /**< ITU-R BT.470-6 System B, G */
775 SDL_TRANSFER_CHARACTERISTICS_BT601 = 6, /**< SMPTE ST 170M / ITU-R BT.601-7 525 or 625 */
776 SDL_TRANSFER_CHARACTERISTICS_SMPTE240 = 7, /**< SMPTE ST 240M */
780 SDL_TRANSFER_CHARACTERISTICS_IEC61966 = 11, /**< IEC 61966-2-4 */
781 SDL_TRANSFER_CHARACTERISTICS_BT1361 = 12, /**< ITU-R BT1361 Extended Colour Gamut */
782 SDL_TRANSFER_CHARACTERISTICS_SRGB = 13, /**< IEC 61966-2-1 (sRGB or sYCC) */
783 SDL_TRANSFER_CHARACTERISTICS_BT2020_10BIT = 14, /**< ITU-R BT2020 for 10-bit system */
784 SDL_TRANSFER_CHARACTERISTICS_BT2020_12BIT = 15, /**< ITU-R BT2020 for 12-bit system */
785 SDL_TRANSFER_CHARACTERISTICS_PQ = 16, /**< SMPTE ST 2084 for 10-, 12-, 14- and 16-bit systems */
786 SDL_TRANSFER_CHARACTERISTICS_SMPTE428 = 17, /**< SMPTE ST 428-1 */
787 SDL_TRANSFER_CHARACTERISTICS_HLG = 18, /**< ARIB STD-B67, known as "hybrid log-gamma" (HLG) */
790
791/**
792 * Colorspace matrix coefficients.
793 *
794 * These are as described by https://www.itu.int/rec/T-REC-H.273-201612-S/en
795 *
796 * \since This enum is available since SDL 3.2.0.
797 */
799{
801 SDL_MATRIX_COEFFICIENTS_BT709 = 1, /**< ITU-R BT.709-6 */
803 SDL_MATRIX_COEFFICIENTS_FCC = 4, /**< US FCC Title 47 */
804 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 */
805 SDL_MATRIX_COEFFICIENTS_BT601 = 6, /**< ITU-R BT.601-7 525 */
806 SDL_MATRIX_COEFFICIENTS_SMPTE240 = 7, /**< SMPTE 240M */
808 SDL_MATRIX_COEFFICIENTS_BT2020_NCL = 9, /**< ITU-R BT.2020-2 non-constant luminance */
809 SDL_MATRIX_COEFFICIENTS_BT2020_CL = 10, /**< ITU-R BT.2020-2 constant luminance */
810 SDL_MATRIX_COEFFICIENTS_SMPTE2085 = 11, /**< SMPTE ST 2085 */
813 SDL_MATRIX_COEFFICIENTS_ICTCP = 14, /**< ITU-R BT.2100-0 ICTCP */
816
817/**
818 * Colorspace chroma sample location.
819 *
820 * \since This enum is available since SDL 3.2.0.
821 */
823{
824 SDL_CHROMA_LOCATION_NONE = 0, /**< RGB, no chroma sampling */
825 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. */
826 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. */
827 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"). */
829
830
831/* Colorspace definition */
832
833/**
834 * A macro for defining custom SDL_Colorspace formats.
835 *
836 * For example, defining SDL_COLORSPACE_SRGB looks like this:
837 *
838 * ```c
839 * SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_RGB,
840 * SDL_COLOR_RANGE_FULL,
841 * SDL_COLOR_PRIMARIES_BT709,
842 * SDL_TRANSFER_CHARACTERISTICS_SRGB,
843 * SDL_MATRIX_COEFFICIENTS_IDENTITY,
844 * SDL_CHROMA_LOCATION_NONE)
845 * ```
846 *
847 * \param type the type of the new format, probably an SDL_ColorType value.
848 * \param range the range of the new format, probably a SDL_ColorRange value.
849 * \param primaries the primaries of the new format, probably an
850 * SDL_ColorPrimaries value.
851 * \param transfer the transfer characteristics of the new format, probably an
852 * SDL_TransferCharacteristics value.
853 * \param matrix the matrix coefficients of the new format, probably an
854 * SDL_MatrixCoefficients value.
855 * \param chroma the chroma sample location of the new format, probably an
856 * SDL_ChromaLocation value.
857 * \returns a format value in the style of SDL_Colorspace.
858 *
859 * \threadsafety It is safe to call this macro from any thread.
860 *
861 * \since This macro is available since SDL 3.2.0.
862 */
863#define SDL_DEFINE_COLORSPACE(type, range, primaries, transfer, matrix, chroma) \
864 (((Uint32)(type) << 28) | ((Uint32)(range) << 24) | ((Uint32)(chroma) << 20) | \
865 ((Uint32)(primaries) << 10) | ((Uint32)(transfer) << 5) | ((Uint32)(matrix) << 0))
866
867/**
868 * A macro to retrieve the type of an SDL_Colorspace.
869 *
870 * \param cspace an SDL_Colorspace to check.
871 * \returns the SDL_ColorType for `cspace`.
872 *
873 * \threadsafety It is safe to call this macro from any thread.
874 *
875 * \since This macro is available since SDL 3.2.0.
876 */
877#define SDL_COLORSPACETYPE(cspace) (SDL_ColorType)(((cspace) >> 28) & 0x0F)
878
879/**
880 * A macro to retrieve the range of an SDL_Colorspace.
881 *
882 * \param cspace an SDL_Colorspace to check.
883 * \returns the SDL_ColorRange of `cspace`.
884 *
885 * \threadsafety It is safe to call this macro from any thread.
886 *
887 * \since This macro is available since SDL 3.2.0.
888 */
889#define SDL_COLORSPACERANGE(cspace) (SDL_ColorRange)(((cspace) >> 24) & 0x0F)
890
891/**
892 * A macro to retrieve the chroma sample location of an SDL_Colorspace.
893 *
894 * \param cspace an SDL_Colorspace to check.
895 * \returns the SDL_ChromaLocation of `cspace`.
896 *
897 * \threadsafety It is safe to call this macro from any thread.
898 *
899 * \since This macro is available since SDL 3.2.0.
900 */
901#define SDL_COLORSPACECHROMA(cspace) (SDL_ChromaLocation)(((cspace) >> 20) & 0x0F)
902
903/**
904 * A macro to retrieve the primaries of an SDL_Colorspace.
905 *
906 * \param cspace an SDL_Colorspace to check.
907 * \returns the SDL_ColorPrimaries of `cspace`.
908 *
909 * \threadsafety It is safe to call this macro from any thread.
910 *
911 * \since This macro is available since SDL 3.2.0.
912 */
913#define SDL_COLORSPACEPRIMARIES(cspace) (SDL_ColorPrimaries)(((cspace) >> 10) & 0x1F)
914
915/**
916 * A macro to retrieve the transfer characteristics of an SDL_Colorspace.
917 *
918 * \param cspace an SDL_Colorspace to check.
919 * \returns the SDL_TransferCharacteristics of `cspace`.
920 *
921 * \threadsafety It is safe to call this macro from any thread.
922 *
923 * \since This macro is available since SDL 3.2.0.
924 */
925#define SDL_COLORSPACETRANSFER(cspace) (SDL_TransferCharacteristics)(((cspace) >> 5) & 0x1F)
926
927/**
928 * A macro to retrieve the matrix coefficients of an SDL_Colorspace.
929 *
930 * \param cspace an SDL_Colorspace to check.
931 * \returns the SDL_MatrixCoefficients of `cspace`.
932 *
933 * \threadsafety It is safe to call this macro from any thread.
934 *
935 * \since This macro is available since SDL 3.2.0.
936 */
937#define SDL_COLORSPACEMATRIX(cspace) (SDL_MatrixCoefficients)((cspace) & 0x1F)
938
939/**
940 * A macro to determine if an SDL_Colorspace uses BT601 (or BT470BG) matrix
941 * coefficients.
942 *
943 * Note that this macro double-evaluates its parameter, so do not use
944 * expressions with side-effects here.
945 *
946 * \param cspace an SDL_Colorspace to check.
947 * \returns true if BT601 or BT470BG, false otherwise.
948 *
949 * \threadsafety It is safe to call this macro from any thread.
950 *
951 * \since This macro is available since SDL 3.2.0.
952 */
953#define SDL_ISCOLORSPACE_MATRIX_BT601(cspace) (SDL_COLORSPACEMATRIX(cspace) == SDL_MATRIX_COEFFICIENTS_BT601 || SDL_COLORSPACEMATRIX(cspace) == SDL_MATRIX_COEFFICIENTS_BT470BG)
954
955/**
956 * A macro to determine if an SDL_Colorspace uses BT709 matrix coefficients.
957 *
958 * \param cspace an SDL_Colorspace to check.
959 * \returns true if BT709, false otherwise.
960 *
961 * \threadsafety It is safe to call this macro from any thread.
962 *
963 * \since This macro is available since SDL 3.2.0.
964 */
965#define SDL_ISCOLORSPACE_MATRIX_BT709(cspace) (SDL_COLORSPACEMATRIX(cspace) == SDL_MATRIX_COEFFICIENTS_BT709)
966
967/**
968 * A macro to determine if an SDL_Colorspace uses BT2020_NCL matrix
969 * coefficients.
970 *
971 * \param cspace an SDL_Colorspace to check.
972 * \returns true if BT2020_NCL, false otherwise.
973 *
974 * \threadsafety It is safe to call this macro from any thread.
975 *
976 * \since This macro is available since SDL 3.2.0.
977 */
978#define SDL_ISCOLORSPACE_MATRIX_BT2020_NCL(cspace) (SDL_COLORSPACEMATRIX(cspace) == SDL_MATRIX_COEFFICIENTS_BT2020_NCL)
979
980/**
981 * A macro to determine if an SDL_Colorspace has a limited range.
982 *
983 * \param cspace an SDL_Colorspace to check.
984 * \returns true if limited range, false otherwise.
985 *
986 * \threadsafety It is safe to call this macro from any thread.
987 *
988 * \since This macro is available since SDL 3.2.0.
989 */
990#define SDL_ISCOLORSPACE_LIMITED_RANGE(cspace) (SDL_COLORSPACERANGE(cspace) != SDL_COLOR_RANGE_FULL)
991
992/**
993 * A macro to determine if an SDL_Colorspace has a full range.
994 *
995 * \param cspace an SDL_Colorspace to check.
996 * \returns true if full range, false otherwise.
997 *
998 * \threadsafety It is safe to call this macro from any thread.
999 *
1000 * \since This macro is available since SDL 3.2.0.
1001 */
1002#define SDL_ISCOLORSPACE_FULL_RANGE(cspace) (SDL_COLORSPACERANGE(cspace) == SDL_COLOR_RANGE_FULL)
1003
1004/**
1005 * Colorspace definitions.
1006 *
1007 * Since similar colorspaces may vary in their details (matrix, transfer
1008 * function, etc.), this is not an exhaustive list, but rather a
1009 * representative sample of the kinds of colorspaces supported in SDL.
1010 *
1011 * \since This enum is available since SDL 3.2.0.
1012 *
1013 * \sa SDL_ColorPrimaries
1014 * \sa SDL_ColorRange
1015 * \sa SDL_ColorType
1016 * \sa SDL_MatrixCoefficients
1017 * \sa SDL_TransferCharacteristics
1018 */
1019typedef enum SDL_Colorspace
1020{
1022
1023 /* sRGB is a gamma corrected colorspace, and the default colorspace for SDL rendering and 8-bit RGB surfaces */
1024 SDL_COLORSPACE_SRGB = 0x120005a0u, /**< Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709 */
1025 /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_RGB,
1026 SDL_COLOR_RANGE_FULL,
1027 SDL_COLOR_PRIMARIES_BT709,
1028 SDL_TRANSFER_CHARACTERISTICS_SRGB,
1029 SDL_MATRIX_COEFFICIENTS_IDENTITY,
1030 SDL_CHROMA_LOCATION_NONE), */
1031
1032 /* 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 */
1033 SDL_COLORSPACE_SRGB_LINEAR = 0x12000500u, /**< Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G10_NONE_P709 */
1034 /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_RGB,
1035 SDL_COLOR_RANGE_FULL,
1036 SDL_COLOR_PRIMARIES_BT709,
1037 SDL_TRANSFER_CHARACTERISTICS_LINEAR,
1038 SDL_MATRIX_COEFFICIENTS_IDENTITY,
1039 SDL_CHROMA_LOCATION_NONE), */
1040
1041 /* HDR10 is a non-linear HDR colorspace and the default colorspace for 10-bit surfaces */
1042 SDL_COLORSPACE_HDR10 = 0x12002600u, /**< Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020 */
1043 /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_RGB,
1044 SDL_COLOR_RANGE_FULL,
1045 SDL_COLOR_PRIMARIES_BT2020,
1046 SDL_TRANSFER_CHARACTERISTICS_PQ,
1047 SDL_MATRIX_COEFFICIENTS_IDENTITY,
1048 SDL_CHROMA_LOCATION_NONE), */
1049
1050 SDL_COLORSPACE_JPEG = 0x220004c6u, /**< Equivalent to DXGI_COLOR_SPACE_YCBCR_FULL_G22_NONE_P709_X601 */
1051 /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_YCBCR,
1052 SDL_COLOR_RANGE_FULL,
1053 SDL_COLOR_PRIMARIES_BT709,
1054 SDL_TRANSFER_CHARACTERISTICS_BT601,
1055 SDL_MATRIX_COEFFICIENTS_BT601,
1056 SDL_CHROMA_LOCATION_NONE), */
1057
1058 SDL_COLORSPACE_BT601_LIMITED = 0x211018c6u, /**< Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601 */
1059 /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_YCBCR,
1060 SDL_COLOR_RANGE_LIMITED,
1061 SDL_COLOR_PRIMARIES_BT601,
1062 SDL_TRANSFER_CHARACTERISTICS_BT601,
1063 SDL_MATRIX_COEFFICIENTS_BT601,
1064 SDL_CHROMA_LOCATION_LEFT), */
1065
1066 SDL_COLORSPACE_BT601_FULL = 0x221018c6u, /**< Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601 */
1067 /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_YCBCR,
1068 SDL_COLOR_RANGE_FULL,
1069 SDL_COLOR_PRIMARIES_BT601,
1070 SDL_TRANSFER_CHARACTERISTICS_BT601,
1071 SDL_MATRIX_COEFFICIENTS_BT601,
1072 SDL_CHROMA_LOCATION_LEFT), */
1073
1074 SDL_COLORSPACE_BT709_LIMITED = 0x21100421u, /**< Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709 */
1075 /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_YCBCR,
1076 SDL_COLOR_RANGE_LIMITED,
1077 SDL_COLOR_PRIMARIES_BT709,
1078 SDL_TRANSFER_CHARACTERISTICS_BT709,
1079 SDL_MATRIX_COEFFICIENTS_BT709,
1080 SDL_CHROMA_LOCATION_LEFT), */
1081
1082 SDL_COLORSPACE_BT709_FULL = 0x22100421u, /**< Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709 */
1083 /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_YCBCR,
1084 SDL_COLOR_RANGE_FULL,
1085 SDL_COLOR_PRIMARIES_BT709,
1086 SDL_TRANSFER_CHARACTERISTICS_BT709,
1087 SDL_MATRIX_COEFFICIENTS_BT709,
1088 SDL_CHROMA_LOCATION_LEFT), */
1089
1090 SDL_COLORSPACE_BT2020_LIMITED = 0x21102609u, /**< Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P2020 */
1091 /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_YCBCR,
1092 SDL_COLOR_RANGE_LIMITED,
1093 SDL_COLOR_PRIMARIES_BT2020,
1094 SDL_TRANSFER_CHARACTERISTICS_PQ,
1095 SDL_MATRIX_COEFFICIENTS_BT2020_NCL,
1096 SDL_CHROMA_LOCATION_LEFT), */
1097
1098 SDL_COLORSPACE_BT2020_FULL = 0x22102609u, /**< Equivalent to DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P2020 */
1099 /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_YCBCR,
1100 SDL_COLOR_RANGE_FULL,
1101 SDL_COLOR_PRIMARIES_BT2020,
1102 SDL_TRANSFER_CHARACTERISTICS_PQ,
1103 SDL_MATRIX_COEFFICIENTS_BT2020_NCL,
1104 SDL_CHROMA_LOCATION_LEFT), */
1105
1106 SDL_COLORSPACE_RGB_DEFAULT = SDL_COLORSPACE_SRGB, /**< The default colorspace for RGB surfaces if no colorspace is specified */
1107 SDL_COLORSPACE_YUV_DEFAULT = SDL_COLORSPACE_BT601_LIMITED /**< The default colorspace for YUV surfaces if no colorspace is specified */
1109
1110/**
1111 * A structure that represents a color as RGBA components.
1112 *
1113 * The bits of this structure can be directly reinterpreted as an
1114 * integer-packed color which uses the SDL_PIXELFORMAT_RGBA32 format
1115 * (SDL_PIXELFORMAT_ABGR8888 on little-endian systems and
1116 * SDL_PIXELFORMAT_RGBA8888 on big-endian systems).
1117 *
1118 * \since This struct is available since SDL 3.2.0.
1119 */
1127
1128/**
1129 * The bits of this structure can be directly reinterpreted as a float-packed
1130 * color which uses the SDL_PIXELFORMAT_RGBA128_FLOAT format
1131 *
1132 * \since This struct is available since SDL 3.2.0.
1133 */
1134typedef struct SDL_FColor
1135{
1136 float r;
1137 float g;
1138 float b;
1139 float a;
1140} SDL_FColor;
1141
1142/**
1143 * A set of indexed colors representing a palette.
1144 *
1145 * \since This struct is available since SDL 3.2.0.
1146 *
1147 * \sa SDL_SetPaletteColors
1148 */
1149typedef struct SDL_Palette
1150{
1151 int ncolors; /**< number of elements in `colors`. */
1152 SDL_Color *colors; /**< an array of colors, `ncolors` long. */
1153 Uint32 version; /**< internal use only, do not touch. */
1154 int refcount; /**< internal use only, do not touch. */
1155} SDL_Palette;
1156
1157/**
1158 * Details about the format of a pixel.
1159 *
1160 * \since This struct is available since SDL 3.2.0.
1161 */
1181
1182/**
1183 * Get the human readable name of a pixel format.
1184 *
1185 * \param format the pixel format to query.
1186 * \returns the human readable name of the specified pixel format or
1187 * "SDL_PIXELFORMAT_UNKNOWN" if the format isn't recognized.
1188 *
1189 * \threadsafety It is safe to call this function from any thread.
1190 *
1191 * \since This function is available since SDL 3.2.0.
1192 */
1193extern SDL_DECLSPEC const char * SDLCALL SDL_GetPixelFormatName(SDL_PixelFormat format);
1194
1195/**
1196 * Convert one of the enumerated pixel formats to a bpp value and RGBA masks.
1197 *
1198 * \param format one of the SDL_PixelFormat values.
1199 * \param bpp a bits per pixel value; usually 15, 16, or 32.
1200 * \param Rmask a pointer filled in with the red mask for the format.
1201 * \param Gmask a pointer filled in with the green mask for the format.
1202 * \param Bmask a pointer filled in with the blue mask for the format.
1203 * \param Amask a pointer filled in with the alpha mask for the format.
1204 * \returns true on success or false on failure; call SDL_GetError() for more
1205 * information.
1206 *
1207 * \threadsafety It is safe to call this function from any thread.
1208 *
1209 * \since This function is available since SDL 3.2.0.
1210 *
1211 * \sa SDL_GetPixelFormatForMasks
1212 */
1213extern SDL_DECLSPEC bool SDLCALL SDL_GetMasksForPixelFormat(SDL_PixelFormat format, int *bpp, Uint32 *Rmask, Uint32 *Gmask, Uint32 *Bmask, Uint32 *Amask);
1214
1215/**
1216 * Convert a bpp value and RGBA masks to an enumerated pixel format.
1217 *
1218 * This will return `SDL_PIXELFORMAT_UNKNOWN` if the conversion wasn't
1219 * possible.
1220 *
1221 * \param bpp a bits per pixel value; usually 15, 16, or 32.
1222 * \param Rmask the red mask for the format.
1223 * \param Gmask the green mask for the format.
1224 * \param Bmask the blue mask for the format.
1225 * \param Amask the alpha mask for the format.
1226 * \returns the SDL_PixelFormat value corresponding to the format masks, or
1227 * SDL_PIXELFORMAT_UNKNOWN if there isn't a match.
1228 *
1229 * \threadsafety It is safe to call this function from any thread.
1230 *
1231 * \since This function is available since SDL 3.2.0.
1232 *
1233 * \sa SDL_GetMasksForPixelFormat
1234 */
1235extern SDL_DECLSPEC SDL_PixelFormat SDLCALL SDL_GetPixelFormatForMasks(int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
1236
1237/**
1238 * Create an SDL_PixelFormatDetails structure corresponding to a pixel format.
1239 *
1240 * Returned structure may come from a shared global cache (i.e. not newly
1241 * allocated), and hence should not be modified, especially the palette. Weird
1242 * errors such as `Blit combination not supported` may occur.
1243 *
1244 * \param format one of the SDL_PixelFormat values.
1245 * \returns a pointer to a SDL_PixelFormatDetails structure or NULL on
1246 * failure; call SDL_GetError() for more information.
1247 *
1248 * \threadsafety It is safe to call this function from any thread.
1249 *
1250 * \since This function is available since SDL 3.2.0.
1251 */
1252extern SDL_DECLSPEC const SDL_PixelFormatDetails * SDLCALL SDL_GetPixelFormatDetails(SDL_PixelFormat format);
1253
1254/**
1255 * Create a palette structure with the specified number of color entries.
1256 *
1257 * If `ncolors` is larger than the palette's size - `firstcolor`, it is
1258 * truncated to the amount that will fit.
1259 *
1260 * The palette entries are initialized to white.
1261 *
1262 * \param ncolors represents the number of color entries in the color palette.
1263 * \returns a new SDL_Palette structure on success or NULL on failure (e.g. if
1264 * there wasn't enough memory); call SDL_GetError() for more
1265 * information.
1266 *
1267 * \threadsafety It is safe to call this function from any thread.
1268 *
1269 * \since This function is available since SDL 3.2.0.
1270 *
1271 * \sa SDL_DestroyPalette
1272 * \sa SDL_SetPaletteColors
1273 * \sa SDL_SetSurfacePalette
1274 */
1275extern SDL_DECLSPEC SDL_Palette * SDLCALL SDL_CreatePalette(int ncolors);
1276
1277/**
1278 * Set a range of colors in a palette.
1279 *
1280 * \param palette the SDL_Palette structure to modify.
1281 * \param colors an array of SDL_Color structures to copy into the palette.
1282 * \param firstcolor the index of the first palette entry to modify.
1283 * \param ncolors the number of entries to modify.
1284 * \returns true on success or false on failure; call SDL_GetError() for more
1285 * information.
1286 *
1287 * \threadsafety It is safe to call this function from any thread, as long as
1288 * the palette is not modified or destroyed in another thread.
1289 *
1290 * \since This function is available since SDL 3.2.0.
1291 */
1292extern SDL_DECLSPEC bool SDLCALL SDL_SetPaletteColors(SDL_Palette *palette, const SDL_Color *colors, int firstcolor, int ncolors);
1293
1294/**
1295 * Free a palette created with SDL_CreatePalette().
1296 *
1297 * \param palette the SDL_Palette structure to be freed.
1298 *
1299 * \threadsafety It is safe to call this function from any thread, as long as
1300 * the palette is not modified or destroyed in another thread.
1301 *
1302 * \since This function is available since SDL 3.2.0.
1303 *
1304 * \sa SDL_CreatePalette
1305 */
1306extern SDL_DECLSPEC void SDLCALL SDL_DestroyPalette(SDL_Palette *palette);
1307
1308/**
1309 * Map an RGB triple to an opaque pixel value for a given pixel format.
1310 *
1311 * This function maps the RGB color value to the specified pixel format and
1312 * returns the pixel value best approximating the given RGB color value for
1313 * the given pixel format.
1314 *
1315 * If the format has a palette (8-bit) the index of the closest matching color
1316 * in the palette will be returned.
1317 *
1318 * If the specified pixel format has an alpha component it will be returned as
1319 * all 1 bits (fully opaque).
1320 *
1321 * If the pixel format bpp (color depth) is less than 32-bpp then the unused
1322 * upper bits of the return value can safely be ignored (e.g., with a 16-bpp
1323 * format the return value can be assigned to a Uint16, and similarly a Uint8
1324 * for an 8-bpp format).
1325 *
1326 * \param format a pointer to SDL_PixelFormatDetails describing the pixel
1327 * format.
1328 * \param palette an optional palette for indexed formats, may be NULL.
1329 * \param r the red component of the pixel in the range 0-255.
1330 * \param g the green component of the pixel in the range 0-255.
1331 * \param b the blue component of the pixel in the range 0-255.
1332 * \returns a pixel value.
1333 *
1334 * \threadsafety It is safe to call this function from any thread, as long as
1335 * the palette is not modified.
1336 *
1337 * \since This function is available since SDL 3.2.0.
1338 *
1339 * \sa SDL_GetPixelFormatDetails
1340 * \sa SDL_GetRGB
1341 * \sa SDL_MapRGBA
1342 * \sa SDL_MapSurfaceRGB
1343 */
1344extern SDL_DECLSPEC Uint32 SDLCALL SDL_MapRGB(const SDL_PixelFormatDetails *format, const SDL_Palette *palette, Uint8 r, Uint8 g, Uint8 b);
1345
1346/**
1347 * Map an RGBA quadruple to a pixel value for a given pixel format.
1348 *
1349 * This function maps the RGBA color value to the specified pixel format and
1350 * returns the pixel value best approximating the given RGBA color value for
1351 * the given pixel format.
1352 *
1353 * If the specified pixel format has no alpha component the alpha value will
1354 * be ignored (as it will be in formats with a palette).
1355 *
1356 * If the format has a palette (8-bit) the index of the closest matching color
1357 * in the palette will be returned.
1358 *
1359 * If the pixel format bpp (color depth) is less than 32-bpp then the unused
1360 * upper bits of the return value can safely be ignored (e.g., with a 16-bpp
1361 * format the return value can be assigned to a Uint16, and similarly a Uint8
1362 * for an 8-bpp format).
1363 *
1364 * \param format a pointer to SDL_PixelFormatDetails describing the pixel
1365 * format.
1366 * \param palette an optional palette for indexed formats, may be NULL.
1367 * \param r the red component of the pixel in the range 0-255.
1368 * \param g the green component of the pixel in the range 0-255.
1369 * \param b the blue component of the pixel in the range 0-255.
1370 * \param a the alpha component of the pixel in the range 0-255.
1371 * \returns a pixel value.
1372 *
1373 * \threadsafety It is safe to call this function from any thread, as long as
1374 * the palette is not modified.
1375 *
1376 * \since This function is available since SDL 3.2.0.
1377 *
1378 * \sa SDL_GetPixelFormatDetails
1379 * \sa SDL_GetRGBA
1380 * \sa SDL_MapRGB
1381 * \sa SDL_MapSurfaceRGBA
1382 */
1383extern SDL_DECLSPEC Uint32 SDLCALL SDL_MapRGBA(const SDL_PixelFormatDetails *format, const SDL_Palette *palette, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
1384
1385/**
1386 * Get RGB values from a pixel in the specified format.
1387 *
1388 * This function uses the entire 8-bit [0..255] range when converting color
1389 * components from pixel formats with less than 8-bits per RGB component
1390 * (e.g., a completely white pixel in 16-bit RGB565 format would return [0xff,
1391 * 0xff, 0xff] not [0xf8, 0xfc, 0xf8]).
1392 *
1393 * \param pixelvalue a pixel value.
1394 * \param format a pointer to SDL_PixelFormatDetails describing the pixel
1395 * format.
1396 * \param palette an optional palette for indexed formats, may be NULL.
1397 * \param r a pointer filled in with the red component, may be NULL.
1398 * \param g a pointer filled in with the green component, may be NULL.
1399 * \param b a pointer filled in with the blue component, may be NULL.
1400 *
1401 * \threadsafety It is safe to call this function from any thread, as long as
1402 * the palette is not modified.
1403 *
1404 * \since This function is available since SDL 3.2.0.
1405 *
1406 * \sa SDL_GetPixelFormatDetails
1407 * \sa SDL_GetRGBA
1408 * \sa SDL_MapRGB
1409 * \sa SDL_MapRGBA
1410 */
1411extern SDL_DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixelvalue, const SDL_PixelFormatDetails *format, const SDL_Palette *palette, Uint8 *r, Uint8 *g, Uint8 *b);
1412
1413/**
1414 * Get RGBA values from a pixel in the specified format.
1415 *
1416 * This function uses the entire 8-bit [0..255] range when converting color
1417 * components from pixel formats with less than 8-bits per RGB component
1418 * (e.g., a completely white pixel in 16-bit RGB565 format would return [0xff,
1419 * 0xff, 0xff] not [0xf8, 0xfc, 0xf8]).
1420 *
1421 * If the format has no alpha component, the alpha will be returned as 0xff
1422 * (100% opaque).
1423 *
1424 * \param pixelvalue a pixel value.
1425 * \param format a pointer to SDL_PixelFormatDetails describing the pixel
1426 * format.
1427 * \param palette an optional palette for indexed formats, may be NULL.
1428 * \param r a pointer filled in with the red component, may be NULL.
1429 * \param g a pointer filled in with the green component, may be NULL.
1430 * \param b a pointer filled in with the blue component, may be NULL.
1431 * \param a a pointer filled in with the alpha component, may be NULL.
1432 *
1433 * \threadsafety It is safe to call this function from any thread, as long as
1434 * the palette is not modified.
1435 *
1436 * \since This function is available since SDL 3.2.0.
1437 *
1438 * \sa SDL_GetPixelFormatDetails
1439 * \sa SDL_GetRGB
1440 * \sa SDL_MapRGB
1441 * \sa SDL_MapRGBA
1442 */
1443extern SDL_DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixelvalue, const SDL_PixelFormatDetails *format, const SDL_Palette *palette, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a);
1444
1445
1446/* Ends C function definitions when using C++ */
1447#ifdef __cplusplus
1448}
1449#endif
1450#include <SDL3/SDL_close_code.h>
1451
1452#endif /* SDL_pixels_h_ */
SDL_MatrixCoefficients
Definition SDL_pixels.h:799
@ SDL_MATRIX_COEFFICIENTS_BT709
Definition SDL_pixels.h:801
@ SDL_MATRIX_COEFFICIENTS_BT2020_CL
Definition SDL_pixels.h:809
@ SDL_MATRIX_COEFFICIENTS_BT601
Definition SDL_pixels.h:805
@ SDL_MATRIX_COEFFICIENTS_BT2020_NCL
Definition SDL_pixels.h:808
@ SDL_MATRIX_COEFFICIENTS_SMPTE240
Definition SDL_pixels.h:806
@ SDL_MATRIX_COEFFICIENTS_YCGCO
Definition SDL_pixels.h:807
@ SDL_MATRIX_COEFFICIENTS_CHROMA_DERIVED_NCL
Definition SDL_pixels.h:811
@ SDL_MATRIX_COEFFICIENTS_CHROMA_DERIVED_CL
Definition SDL_pixels.h:812
@ SDL_MATRIX_COEFFICIENTS_UNSPECIFIED
Definition SDL_pixels.h:802
@ SDL_MATRIX_COEFFICIENTS_CUSTOM
Definition SDL_pixels.h:814
@ SDL_MATRIX_COEFFICIENTS_ICTCP
Definition SDL_pixels.h:813
@ SDL_MATRIX_COEFFICIENTS_IDENTITY
Definition SDL_pixels.h:800
@ SDL_MATRIX_COEFFICIENTS_FCC
Definition SDL_pixels.h:803
@ SDL_MATRIX_COEFFICIENTS_BT470BG
Definition SDL_pixels.h:804
@ SDL_MATRIX_COEFFICIENTS_SMPTE2085
Definition SDL_pixels.h:810
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:731
@ SDL_COLOR_RANGE_LIMITED
Definition SDL_pixels.h:733
@ SDL_COLOR_RANGE_FULL
Definition SDL_pixels.h:734
@ SDL_COLOR_RANGE_UNKNOWN
Definition SDL_pixels.h:732
SDL_ColorPrimaries
Definition SDL_pixels.h:744
@ SDL_COLOR_PRIMARIES_SMPTE431
Definition SDL_pixels.h:755
@ SDL_COLOR_PRIMARIES_CUSTOM
Definition SDL_pixels.h:758
@ SDL_COLOR_PRIMARIES_EBU3213
Definition SDL_pixels.h:757
@ SDL_COLOR_PRIMARIES_GENERIC_FILM
Definition SDL_pixels.h:752
@ SDL_COLOR_PRIMARIES_BT601
Definition SDL_pixels.h:750
@ SDL_COLOR_PRIMARIES_UNSPECIFIED
Definition SDL_pixels.h:747
@ SDL_COLOR_PRIMARIES_SMPTE240
Definition SDL_pixels.h:751
@ SDL_COLOR_PRIMARIES_XYZ
Definition SDL_pixels.h:754
@ SDL_COLOR_PRIMARIES_UNKNOWN
Definition SDL_pixels.h:745
@ SDL_COLOR_PRIMARIES_SMPTE432
Definition SDL_pixels.h:756
@ SDL_COLOR_PRIMARIES_BT2020
Definition SDL_pixels.h:753
@ SDL_COLOR_PRIMARIES_BT470BG
Definition SDL_pixels.h:749
@ SDL_COLOR_PRIMARIES_BT709
Definition SDL_pixels.h:746
@ SDL_COLOR_PRIMARIES_BT470M
Definition SDL_pixels.h:748
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:823
@ SDL_CHROMA_LOCATION_NONE
Definition SDL_pixels.h:824
@ SDL_CHROMA_LOCATION_TOPLEFT
Definition SDL_pixels.h:827
@ SDL_CHROMA_LOCATION_CENTER
Definition SDL_pixels.h:826
@ SDL_CHROMA_LOCATION_LEFT
Definition SDL_pixels.h:825
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)
void SDL_GetRGBA(Uint32 pixelvalue, const SDL_PixelFormatDetails *format, const SDL_Palette *palette, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a)
SDL_ColorType
Definition SDL_pixels.h:718
@ SDL_COLOR_TYPE_RGB
Definition SDL_pixels.h:720
@ SDL_COLOR_TYPE_YCBCR
Definition SDL_pixels.h:721
@ SDL_COLOR_TYPE_UNKNOWN
Definition SDL_pixels.h:719
SDL_TransferCharacteristics
Definition SDL_pixels.h:769
@ SDL_TRANSFER_CHARACTERISTICS_BT709
Definition SDL_pixels.h:771
@ SDL_TRANSFER_CHARACTERISTICS_BT1361
Definition SDL_pixels.h:781
@ SDL_TRANSFER_CHARACTERISTICS_CUSTOM
Definition SDL_pixels.h:788
@ SDL_TRANSFER_CHARACTERISTICS_HLG
Definition SDL_pixels.h:787
@ SDL_TRANSFER_CHARACTERISTICS_LOG100_SQRT10
Definition SDL_pixels.h:779
@ SDL_TRANSFER_CHARACTERISTICS_UNKNOWN
Definition SDL_pixels.h:770
@ SDL_TRANSFER_CHARACTERISTICS_BT601
Definition SDL_pixels.h:775
@ SDL_TRANSFER_CHARACTERISTICS_IEC61966
Definition SDL_pixels.h:780
@ SDL_TRANSFER_CHARACTERISTICS_UNSPECIFIED
Definition SDL_pixels.h:772
@ SDL_TRANSFER_CHARACTERISTICS_SMPTE428
Definition SDL_pixels.h:786
@ SDL_TRANSFER_CHARACTERISTICS_LOG100
Definition SDL_pixels.h:778
@ SDL_TRANSFER_CHARACTERISTICS_GAMMA28
Definition SDL_pixels.h:774
@ SDL_TRANSFER_CHARACTERISTICS_SMPTE240
Definition SDL_pixels.h:776
@ SDL_TRANSFER_CHARACTERISTICS_BT2020_10BIT
Definition SDL_pixels.h:783
@ SDL_TRANSFER_CHARACTERISTICS_SRGB
Definition SDL_pixels.h:782
@ SDL_TRANSFER_CHARACTERISTICS_PQ
Definition SDL_pixels.h:785
@ SDL_TRANSFER_CHARACTERISTICS_LINEAR
Definition SDL_pixels.h:777
@ SDL_TRANSFER_CHARACTERISTICS_BT2020_12BIT
Definition SDL_pixels.h:784
@ SDL_TRANSFER_CHARACTERISTICS_GAMMA22
Definition SDL_pixels.h:773
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:551
@ SDL_PIXELFORMAT_BGR48_FLOAT
Definition SDL_pixels.h:639
@ SDL_PIXELFORMAT_RGBA128_FLOAT
Definition SDL_pixels.h:653
@ SDL_PIXELFORMAT_BGR565
Definition SDL_pixels.h:595
@ SDL_PIXELFORMAT_P010
Definition SDL_pixels.h:678
@ SDL_PIXELFORMAT_EXTERNAL_OES
Definition SDL_pixels.h:684
@ SDL_PIXELFORMAT_ARGB64
Definition SDL_pixels.h:631
@ SDL_PIXELFORMAT_YVYU
Definition SDL_pixels.h:670
@ SDL_PIXELFORMAT_RGB332
Definition SDL_pixels.h:567
@ SDL_PIXELFORMAT_INDEX2LSB
Definition SDL_pixels.h:557
@ SDL_PIXELFORMAT_INDEX1LSB
Definition SDL_pixels.h:553
@ SDL_PIXELFORMAT_RGB96_FLOAT
Definition SDL_pixels.h:649
@ SDL_PIXELFORMAT_RGBX32
Definition SDL_pixels.h:696
@ SDL_PIXELFORMAT_ABGR4444
Definition SDL_pixels.h:581
@ SDL_PIXELFORMAT_BGRA4444
Definition SDL_pixels.h:583
@ SDL_PIXELFORMAT_BGR24
Definition SDL_pixels.h:599
@ SDL_PIXELFORMAT_INDEX4MSB
Definition SDL_pixels.h:563
@ SDL_PIXELFORMAT_ABGR2101010
Definition SDL_pixels.h:623
@ SDL_PIXELFORMAT_BGRA32
Definition SDL_pixels.h:694
@ SDL_PIXELFORMAT_XBGR2101010
Definition SDL_pixels.h:619
@ SDL_PIXELFORMAT_RGBA64_FLOAT
Definition SDL_pixels.h:641
@ SDL_PIXELFORMAT_INDEX2MSB
Definition SDL_pixels.h:559
@ SDL_PIXELFORMAT_BGRA64_FLOAT
Definition SDL_pixels.h:645
@ SDL_PIXELFORMAT_MJPG
Definition SDL_pixels.h:687
@ SDL_PIXELFORMAT_RGBA8888
Definition SDL_pixels.h:611
@ SDL_PIXELFORMAT_RGBA5551
Definition SDL_pixels.h:587
@ SDL_PIXELFORMAT_ARGB1555
Definition SDL_pixels.h:585
@ SDL_PIXELFORMAT_XBGR4444
Definition SDL_pixels.h:571
@ SDL_PIXELFORMAT_RGBA64
Definition SDL_pixels.h:629
@ SDL_PIXELFORMAT_INDEX8
Definition SDL_pixels.h:565
@ SDL_PIXELFORMAT_XRGB2101010
Definition SDL_pixels.h:617
@ SDL_PIXELFORMAT_XRGB8888
Definition SDL_pixels.h:601
@ SDL_PIXELFORMAT_UYVY
Definition SDL_pixels.h:668
@ SDL_PIXELFORMAT_BGRX32
Definition SDL_pixels.h:698
@ SDL_PIXELFORMAT_YV12
Definition SDL_pixels.h:662
@ SDL_PIXELFORMAT_ABGR32
Definition SDL_pixels.h:695
@ SDL_PIXELFORMAT_BGRX8888
Definition SDL_pixels.h:607
@ SDL_PIXELFORMAT_RGB24
Definition SDL_pixels.h:597
@ SDL_PIXELFORMAT_BGRA64
Definition SDL_pixels.h:633
@ SDL_PIXELFORMAT_ABGR8888
Definition SDL_pixels.h:613
@ SDL_PIXELFORMAT_I0FL
Definition SDL_pixels.h:680
@ SDL_PIXELFORMAT_YUY2
Definition SDL_pixels.h:666
@ SDL_PIXELFORMAT_I4FL
Definition SDL_pixels.h:682
@ SDL_PIXELFORMAT_XBGR32
Definition SDL_pixels.h:699
@ SDL_PIXELFORMAT_NV12
Definition SDL_pixels.h:672
@ SDL_PIXELFORMAT_BGRA8888
Definition SDL_pixels.h:615
@ SDL_PIXELFORMAT_ABGR128_FLOAT
Definition SDL_pixels.h:659
@ SDL_PIXELFORMAT_ARGB32
Definition SDL_pixels.h:693
@ SDL_PIXELFORMAT_ABGR1555
Definition SDL_pixels.h:589
@ SDL_PIXELFORMAT_NV21
Definition SDL_pixels.h:674
@ SDL_PIXELFORMAT_IYUV
Definition SDL_pixels.h:664
@ SDL_PIXELFORMAT_ARGB8888
Definition SDL_pixels.h:609
@ SDL_PIXELFORMAT_ABGR64_FLOAT
Definition SDL_pixels.h:647
@ SDL_PIXELFORMAT_ABGR64
Definition SDL_pixels.h:635
@ SDL_PIXELFORMAT_XRGB32
Definition SDL_pixels.h:697
@ SDL_PIXELFORMAT_XBGR1555
Definition SDL_pixels.h:575
@ SDL_PIXELFORMAT_RGB48
Definition SDL_pixels.h:625
@ SDL_PIXELFORMAT_XRGB4444
Definition SDL_pixels.h:569
@ SDL_PIXELFORMAT_BGR96_FLOAT
Definition SDL_pixels.h:651
@ SDL_PIXELFORMAT_ARGB4444
Definition SDL_pixels.h:577
@ SDL_PIXELFORMAT_RGB48_FLOAT
Definition SDL_pixels.h:637
@ SDL_PIXELFORMAT_BGR48
Definition SDL_pixels.h:627
@ SDL_PIXELFORMAT_RGBA32
Definition SDL_pixels.h:692
@ SDL_PIXELFORMAT_BGRA128_FLOAT
Definition SDL_pixels.h:657
@ SDL_PIXELFORMAT_ARGB64_FLOAT
Definition SDL_pixels.h:643
@ SDL_PIXELFORMAT_INDEX1MSB
Definition SDL_pixels.h:555
@ SDL_PIXELFORMAT_INDEX4LSB
Definition SDL_pixels.h:561
@ SDL_PIXELFORMAT_RGBX8888
Definition SDL_pixels.h:603
@ SDL_PIXELFORMAT_BGRA5551
Definition SDL_pixels.h:591
@ SDL_PIXELFORMAT_ARGB128_FLOAT
Definition SDL_pixels.h:655
@ SDL_PIXELFORMAT_XRGB1555
Definition SDL_pixels.h:573
@ SDL_PIXELFORMAT_RGB565
Definition SDL_pixels.h:593
@ SDL_PIXELFORMAT_XBGR8888
Definition SDL_pixels.h:605
@ SDL_PIXELFORMAT_ARGB2101010
Definition SDL_pixels.h:621
@ SDL_PIXELFORMAT_UNKNOWN
Definition SDL_pixels.h:552
@ SDL_PIXELFORMAT_I444
Definition SDL_pixels.h:676
@ SDL_PIXELFORMAT_RGBA4444
Definition SDL_pixels.h:579
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_GetRGB(Uint32 pixelvalue, const SDL_PixelFormatDetails *format, const SDL_Palette *palette, Uint8 *r, Uint8 *g, Uint8 *b)
uint8_t Uint8
Definition SDL_stdinc.h:459
uint32_t Uint32
Definition SDL_stdinc.h:495
Uint32 version
SDL_Color * colors
SDL_PixelFormat format