SDL 3.0
SDL_pixels.h File Reference
+ Include dependency graph for SDL_pixels.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  SDL_Color
 
struct  SDL_Palette
 
struct  SDL_PixelFormat
 

Transparency definitions

These define alpha as the opacity of a surface.

#define SDL_ALPHA_OPAQUE   255
 
#define SDL_ALPHA_TRANSPARENT   0
 
#define SDL_DEFINE_PIXELFOURCC(A, B, C, D)   SDL_FOURCC(A, B, C, D)
 
#define SDL_DEFINE_PIXELFORMAT(type, order, layout, bits, bytes)
 
#define SDL_PIXELFLAG(X)   (((X) >> 28) & 0x0F)
 
#define SDL_PIXELTYPE(X)   (((X) >> 24) & 0x0F)
 
#define SDL_PIXELORDER(X)   (((X) >> 20) & 0x0F)
 
#define SDL_PIXELLAYOUT(X)   (((X) >> 16) & 0x0F)
 
#define SDL_BITSPERPIXEL(X)   (((X) >> 8) & 0xFF)
 
#define SDL_BYTESPERPIXEL(X)
 
#define SDL_ISPIXELFORMAT_INDEXED(format)
 
#define SDL_ISPIXELFORMAT_PACKED(format)
 
#define SDL_ISPIXELFORMAT_ARRAY(format)
 
#define SDL_ISPIXELFORMAT_ALPHA(format)
 
#define SDL_ISPIXELFORMAT_10BIT(format)
 
#define SDL_ISPIXELFORMAT_FOURCC(format)    ((format) && (SDL_PIXELFLAG(format) != 1))
 
#define SDL_Colour   SDL_Color
 
enum  SDL_PixelType {
  SDL_PIXELTYPE_UNKNOWN ,
  SDL_PIXELTYPE_INDEX1 ,
  SDL_PIXELTYPE_INDEX4 ,
  SDL_PIXELTYPE_INDEX8 ,
  SDL_PIXELTYPE_PACKED8 ,
  SDL_PIXELTYPE_PACKED16 ,
  SDL_PIXELTYPE_PACKED32 ,
  SDL_PIXELTYPE_ARRAYU8 ,
  SDL_PIXELTYPE_ARRAYU16 ,
  SDL_PIXELTYPE_ARRAYU32 ,
  SDL_PIXELTYPE_ARRAYF16 ,
  SDL_PIXELTYPE_ARRAYF32 ,
  SDL_PIXELTYPE_INDEX2
}
 
enum  SDL_BitmapOrder {
  SDL_BITMAPORDER_NONE ,
  SDL_BITMAPORDER_4321 ,
  SDL_BITMAPORDER_1234
}
 
enum  SDL_PackedOrder {
  SDL_PACKEDORDER_NONE ,
  SDL_PACKEDORDER_XRGB ,
  SDL_PACKEDORDER_RGBX ,
  SDL_PACKEDORDER_ARGB ,
  SDL_PACKEDORDER_RGBA ,
  SDL_PACKEDORDER_XBGR ,
  SDL_PACKEDORDER_BGRX ,
  SDL_PACKEDORDER_ABGR ,
  SDL_PACKEDORDER_BGRA
}
 
enum  SDL_ArrayOrder {
  SDL_ARRAYORDER_NONE ,
  SDL_ARRAYORDER_RGB ,
  SDL_ARRAYORDER_UNUSED1 ,
  SDL_ARRAYORDER_UNUSED2 ,
  SDL_ARRAYORDER_BGR
}
 
enum  SDL_PackedLayout {
  SDL_PACKEDLAYOUT_NONE ,
  SDL_PACKEDLAYOUT_332 ,
  SDL_PACKEDLAYOUT_4444 ,
  SDL_PACKEDLAYOUT_1555 ,
  SDL_PACKEDLAYOUT_5551 ,
  SDL_PACKEDLAYOUT_565 ,
  SDL_PACKEDLAYOUT_8888 ,
  SDL_PACKEDLAYOUT_2101010 ,
  SDL_PACKEDLAYOUT_1010102
}
 
enum  SDL_PixelFormatEnum {
  SDL_PIXELFORMAT_UNKNOWN ,
  SDL_PIXELFORMAT_INDEX1LSB ,
  SDL_PIXELFORMAT_INDEX1MSB ,
  SDL_PIXELFORMAT_INDEX2LSB ,
  SDL_PIXELFORMAT_INDEX2MSB ,
  SDL_PIXELFORMAT_INDEX4LSB ,
  SDL_PIXELFORMAT_INDEX4MSB ,
  SDL_PIXELFORMAT_INDEX8 ,
  SDL_PIXELFORMAT_RGB332 ,
  SDL_PIXELFORMAT_XRGB4444 ,
  SDL_PIXELFORMAT_RGB444 = SDL_PIXELFORMAT_XRGB4444 ,
  SDL_PIXELFORMAT_XBGR4444 ,
  SDL_PIXELFORMAT_BGR444 = SDL_PIXELFORMAT_XBGR4444 ,
  SDL_PIXELFORMAT_XRGB1555 ,
  SDL_PIXELFORMAT_RGB555 = SDL_PIXELFORMAT_XRGB1555 ,
  SDL_PIXELFORMAT_XBGR1555 ,
  SDL_PIXELFORMAT_BGR555 = SDL_PIXELFORMAT_XBGR1555 ,
  SDL_PIXELFORMAT_ARGB4444 ,
  SDL_PIXELFORMAT_RGBA4444 ,
  SDL_PIXELFORMAT_ABGR4444 ,
  SDL_PIXELFORMAT_BGRA4444 ,
  SDL_PIXELFORMAT_ARGB1555 ,
  SDL_PIXELFORMAT_RGBA5551 ,
  SDL_PIXELFORMAT_ABGR1555 ,
  SDL_PIXELFORMAT_BGRA5551 ,
  SDL_PIXELFORMAT_RGB565 ,
  SDL_PIXELFORMAT_BGR565 ,
  SDL_PIXELFORMAT_RGB24 ,
  SDL_PIXELFORMAT_BGR24 ,
  SDL_PIXELFORMAT_XRGB8888 ,
  SDL_PIXELFORMAT_RGBX8888 ,
  SDL_PIXELFORMAT_XBGR8888 ,
  SDL_PIXELFORMAT_BGRX8888 ,
  SDL_PIXELFORMAT_ARGB8888 ,
  SDL_PIXELFORMAT_RGBA8888 ,
  SDL_PIXELFORMAT_ABGR8888 ,
  SDL_PIXELFORMAT_BGRA8888 ,
  SDL_PIXELFORMAT_XRGB2101010 ,
  SDL_PIXELFORMAT_XBGR2101010 ,
  SDL_PIXELFORMAT_ARGB2101010 ,
  SDL_PIXELFORMAT_ABGR2101010 ,
  SDL_PIXELFORMAT_RGBA32 = SDL_PIXELFORMAT_RGBA8888 ,
  SDL_PIXELFORMAT_ARGB32 = SDL_PIXELFORMAT_ARGB8888 ,
  SDL_PIXELFORMAT_BGRA32 = SDL_PIXELFORMAT_BGRA8888 ,
  SDL_PIXELFORMAT_ABGR32 = SDL_PIXELFORMAT_ABGR8888 ,
  SDL_PIXELFORMAT_RGBX32 = SDL_PIXELFORMAT_RGBX8888 ,
  SDL_PIXELFORMAT_XRGB32 = SDL_PIXELFORMAT_XRGB8888 ,
  SDL_PIXELFORMAT_BGRX32 = SDL_PIXELFORMAT_BGRX8888 ,
  SDL_PIXELFORMAT_XBGR32 = SDL_PIXELFORMAT_XBGR8888 ,
  SDL_PIXELFORMAT_YV12 ,
  SDL_PIXELFORMAT_IYUV ,
  SDL_PIXELFORMAT_YUY2 ,
  SDL_PIXELFORMAT_UYVY ,
  SDL_PIXELFORMAT_YVYU ,
  SDL_PIXELFORMAT_NV12 ,
  SDL_PIXELFORMAT_NV21 ,
  SDL_PIXELFORMAT_EXTERNAL_OES =
}
 
const char * SDL_GetPixelFormatName (Uint32 format)
 
SDL_bool SDL_GetMasksForPixelFormatEnum (Uint32 format, int *bpp, Uint32 *Rmask, Uint32 *Gmask, Uint32 *Bmask, Uint32 *Amask)
 
Uint32 SDL_GetPixelFormatEnumForMasks (int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
 
SDL_PixelFormatSDL_CreatePixelFormat (Uint32 pixel_format)
 
void SDL_DestroyPixelFormat (SDL_PixelFormat *format)
 
SDL_PaletteSDL_CreatePalette (int ncolors)
 
int SDL_SetPixelFormatPalette (SDL_PixelFormat *format, SDL_Palette *palette)
 
int SDL_SetPaletteColors (SDL_Palette *palette, const SDL_Color *colors, int firstcolor, int ncolors)
 
void SDL_DestroyPalette (SDL_Palette *palette)
 
Uint32 SDL_MapRGB (const SDL_PixelFormat *format, Uint8 r, Uint8 g, Uint8 b)
 
Uint32 SDL_MapRGBA (const SDL_PixelFormat *format, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
 
void SDL_GetRGB (Uint32 pixel, const SDL_PixelFormat *format, Uint8 *r, Uint8 *g, Uint8 *b)
 
void SDL_GetRGBA (Uint32 pixel, const SDL_PixelFormat *format, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a)
 

Detailed Description

Header for the enumerated pixel format definitions.

SDL's pixel formats have the following naming convention:

* Names with a list of components and a single bit count, such as
  RGB24 and ABGR32, define a platform-independent encoding into
  bytes in the order specified. For example, in RGB24 data, each
  pixel is encoded in 3 bytes (red, green, blue) in that order,
  and in ABGR32 data, each pixel is encoded in 4 bytes
  (alpha, blue, green, red) in that order. Use these names if the
  property of a format that is important to you is the order of
  the bytes in memory or on disk.

* Names with a bit count per component, such as ARGB8888 and
  XRGB1555, are "packed" into an appropriately-sized integer in
  the platform's native endianness. For example, ARGB8888 is
  a sequence of 32-bit integers; in each integer, the most
  significant bits are alpha, and the least significant bits are
  blue. On a little-endian CPU such as x86, the least significant
  bits of each integer are arranged first in memory, but on a
  big-endian CPU such as s390x, the most significant bits are
  arranged first. Use these names if the property of a format that
  is important to you is the meaning of each bit position within a
  native-endianness integer.

* In indexed formats such as INDEX4LSB, each pixel is represented
  by encoding an index into the palette into the indicated number
  of bits, with multiple pixels packed into each byte if appropriate.
  In LSB formats, the first (leftmost) pixel is stored in the
  least-significant bits of the byte; in MSB formats, it's stored
  in the most-significant bits. INDEX8 does not need LSB/MSB
  variants, because each pixel exactly fills one byte.

The 32-bit byte-array encodings such as RGBA32 are aliases for the appropriate 8888 encoding for the current platform. For example, RGBA32 is an alias for ABGR8888 on little-endian CPUs like x86, or an alias for RGBA8888 on big-endian CPUs.

Definition in file SDL_pixels.h.

Macro Definition Documentation

◆ SDL_ALPHA_OPAQUE

#define SDL_ALPHA_OPAQUE   255

Definition at line 82 of file SDL_pixels.h.

◆ SDL_ALPHA_TRANSPARENT

#define SDL_ALPHA_TRANSPARENT   0

Definition at line 83 of file SDL_pixels.h.

◆ SDL_BITSPERPIXEL

#define SDL_BITSPERPIXEL (   X)    (((X) >> 8) & 0xFF)

Definition at line 161 of file SDL_pixels.h.

◆ SDL_BYTESPERPIXEL

#define SDL_BYTESPERPIXEL (   X)
Value:
((((X) == SDL_PIXELFORMAT_YUY2) || \
((X) == SDL_PIXELFORMAT_UYVY) || \
((X) == SDL_PIXELFORMAT_YVYU)) ? 2 : 1) : (((X) >> 0) & 0xFF))
@ SDL_PIXELFORMAT_YVYU
Definition SDL_pixels.h:349
@ SDL_PIXELFORMAT_UYVY
Definition SDL_pixels.h:347
@ SDL_PIXELFORMAT_YUY2
Definition SDL_pixels.h:345
#define SDL_ISPIXELFORMAT_FOURCC(format)
Definition SDL_pixels.h:201

Definition at line 162 of file SDL_pixels.h.

166 : 1) : (((X) >> 0) & 0xFF))

◆ SDL_Colour

#define SDL_Colour   SDL_Color

Definition at line 371 of file SDL_pixels.h.

◆ SDL_DEFINE_PIXELFORMAT

#define SDL_DEFINE_PIXELFORMAT (   type,
  order,
  layout,
  bits,
  bytes 
)
Value:
((1 << 28) | ((type) << 24) | ((order) << 20) | ((layout) << 16) | \
((bits) << 8) | ((bytes) << 0))

Definition at line 153 of file SDL_pixels.h.

◆ SDL_DEFINE_PIXELFOURCC

#define SDL_DEFINE_PIXELFOURCC (   A,
  B,
  C,
 
)    SDL_FOURCC(A, B, C, D)

Definition at line 151 of file SDL_pixels.h.

◆ SDL_ISPIXELFORMAT_10BIT

#define SDL_ISPIXELFORMAT_10BIT (   format)
Value:
@ SDL_PIXELTYPE_PACKED32
Definition SDL_pixels.h:95
@ SDL_PACKEDLAYOUT_2101010
Definition SDL_pixels.h:147
#define SDL_PIXELLAYOUT(X)
Definition SDL_pixels.h:160
#define SDL_PIXELTYPE(X)
Definition SDL_pixels.h:158

Definition at line 196 of file SDL_pixels.h.

◆ SDL_ISPIXELFORMAT_ALPHA

#define SDL_ISPIXELFORMAT_ALPHA (   format)
Value:
((SDL_ISPIXELFORMAT_PACKED(format) && \
#define SDL_ISPIXELFORMAT_PACKED(format)
Definition SDL_pixels.h:175
#define SDL_PIXELORDER(X)
Definition SDL_pixels.h:159
@ SDL_PACKEDORDER_RGBA
Definition SDL_pixels.h:120
@ SDL_PACKEDORDER_ABGR
Definition SDL_pixels.h:123
@ SDL_PACKEDORDER_BGRA
Definition SDL_pixels.h:124
@ SDL_PACKEDORDER_ARGB
Definition SDL_pixels.h:119

Definition at line 189 of file SDL_pixels.h.

◆ SDL_ISPIXELFORMAT_ARRAY

#define SDL_ISPIXELFORMAT_ARRAY (   format)
Value:
(!SDL_ISPIXELFORMAT_FOURCC(format) && \
@ SDL_PIXELTYPE_ARRAYU16
Definition SDL_pixels.h:97
@ SDL_PIXELTYPE_ARRAYU8
Definition SDL_pixels.h:96
@ SDL_PIXELTYPE_ARRAYF16
Definition SDL_pixels.h:99
@ SDL_PIXELTYPE_ARRAYU32
Definition SDL_pixels.h:98
@ SDL_PIXELTYPE_ARRAYF32
Definition SDL_pixels.h:100

Definition at line 181 of file SDL_pixels.h.

◆ SDL_ISPIXELFORMAT_FOURCC

#define SDL_ISPIXELFORMAT_FOURCC (   format)     ((format) && (SDL_PIXELFLAG(format) != 1))

Definition at line 201 of file SDL_pixels.h.

◆ SDL_ISPIXELFORMAT_INDEXED

#define SDL_ISPIXELFORMAT_INDEXED (   format)
Value:
(!SDL_ISPIXELFORMAT_FOURCC(format) && \
@ SDL_PIXELTYPE_INDEX2
Definition SDL_pixels.h:102
@ SDL_PIXELTYPE_INDEX4
Definition SDL_pixels.h:91
@ SDL_PIXELTYPE_INDEX1
Definition SDL_pixels.h:90
@ SDL_PIXELTYPE_INDEX8
Definition SDL_pixels.h:92

Definition at line 168 of file SDL_pixels.h.

◆ SDL_ISPIXELFORMAT_PACKED

#define SDL_ISPIXELFORMAT_PACKED (   format)
Value:
(!SDL_ISPIXELFORMAT_FOURCC(format) && \
@ SDL_PIXELTYPE_PACKED8
Definition SDL_pixels.h:93
@ SDL_PIXELTYPE_PACKED16
Definition SDL_pixels.h:94

Definition at line 175 of file SDL_pixels.h.

◆ SDL_PIXELFLAG

#define SDL_PIXELFLAG (   X)    (((X) >> 28) & 0x0F)

Definition at line 157 of file SDL_pixels.h.

◆ SDL_PIXELLAYOUT

#define SDL_PIXELLAYOUT (   X)    (((X) >> 16) & 0x0F)

Definition at line 160 of file SDL_pixels.h.

◆ SDL_PIXELORDER

#define SDL_PIXELORDER (   X)    (((X) >> 20) & 0x0F)

Definition at line 159 of file SDL_pixels.h.

◆ SDL_PIXELTYPE

#define SDL_PIXELTYPE (   X)    (((X) >> 24) & 0x0F)

Definition at line 158 of file SDL_pixels.h.

Enumeration Type Documentation

◆ SDL_ArrayOrder

Array component order, low byte -> high byte.

Enumerator
SDL_ARRAYORDER_NONE 
SDL_ARRAYORDER_RGB 
SDL_ARRAYORDER_UNUSED1 
SDL_ARRAYORDER_UNUSED2 
SDL_ARRAYORDER_BGR 

Definition at line 128 of file SDL_pixels.h.

129{
132 SDL_ARRAYORDER_UNUSED1, /* Left for compatibility with SDL2 */
133 SDL_ARRAYORDER_UNUSED2, /* Left for compatibility with SDL2 */
SDL_ArrayOrder
Definition SDL_pixels.h:129
@ SDL_ARRAYORDER_RGB
Definition SDL_pixels.h:131
@ SDL_ARRAYORDER_UNUSED1
Definition SDL_pixels.h:132
@ SDL_ARRAYORDER_NONE
Definition SDL_pixels.h:130
@ SDL_ARRAYORDER_BGR
Definition SDL_pixels.h:134
@ SDL_ARRAYORDER_UNUSED2
Definition SDL_pixels.h:133

◆ SDL_BitmapOrder

Bitmap pixel order, high bit -> low bit.

Enumerator
SDL_BITMAPORDER_NONE 
SDL_BITMAPORDER_4321 
SDL_BITMAPORDER_1234 

Definition at line 106 of file SDL_pixels.h.

107{
SDL_BitmapOrder
Definition SDL_pixels.h:107
@ SDL_BITMAPORDER_1234
Definition SDL_pixels.h:110
@ SDL_BITMAPORDER_NONE
Definition SDL_pixels.h:108
@ SDL_BITMAPORDER_4321
Definition SDL_pixels.h:109

◆ SDL_PackedLayout

Packed component layout.

Enumerator
SDL_PACKEDLAYOUT_NONE 
SDL_PACKEDLAYOUT_332 
SDL_PACKEDLAYOUT_4444 
SDL_PACKEDLAYOUT_1555 
SDL_PACKEDLAYOUT_5551 
SDL_PACKEDLAYOUT_565 
SDL_PACKEDLAYOUT_8888 
SDL_PACKEDLAYOUT_2101010 
SDL_PACKEDLAYOUT_1010102 

Definition at line 138 of file SDL_pixels.h.

139{
SDL_PackedLayout
Definition SDL_pixels.h:139
@ SDL_PACKEDLAYOUT_NONE
Definition SDL_pixels.h:140
@ SDL_PACKEDLAYOUT_8888
Definition SDL_pixels.h:146
@ SDL_PACKEDLAYOUT_1010102
Definition SDL_pixels.h:148
@ SDL_PACKEDLAYOUT_565
Definition SDL_pixels.h:145
@ SDL_PACKEDLAYOUT_332
Definition SDL_pixels.h:141
@ SDL_PACKEDLAYOUT_5551
Definition SDL_pixels.h:144
@ SDL_PACKEDLAYOUT_1555
Definition SDL_pixels.h:143
@ SDL_PACKEDLAYOUT_4444
Definition SDL_pixels.h:142

◆ SDL_PackedOrder

Packed component order, high bit -> low bit.

Enumerator
SDL_PACKEDORDER_NONE 
SDL_PACKEDORDER_XRGB 
SDL_PACKEDORDER_RGBX 
SDL_PACKEDORDER_ARGB 
SDL_PACKEDORDER_RGBA 
SDL_PACKEDORDER_XBGR 
SDL_PACKEDORDER_BGRX 
SDL_PACKEDORDER_ABGR 
SDL_PACKEDORDER_BGRA 

Definition at line 114 of file SDL_pixels.h.

◆ SDL_PixelFormatEnum

Enumerator
SDL_PIXELFORMAT_UNKNOWN 
SDL_PIXELFORMAT_INDEX1LSB 
SDL_PIXELFORMAT_INDEX1MSB 
SDL_PIXELFORMAT_INDEX2LSB 
SDL_PIXELFORMAT_INDEX2MSB 
SDL_PIXELFORMAT_INDEX4LSB 
SDL_PIXELFORMAT_INDEX4MSB 
SDL_PIXELFORMAT_INDEX8 
SDL_PIXELFORMAT_RGB332 
SDL_PIXELFORMAT_XRGB4444 
SDL_PIXELFORMAT_RGB444 
SDL_PIXELFORMAT_XBGR4444 
SDL_PIXELFORMAT_BGR444 
SDL_PIXELFORMAT_XRGB1555 
SDL_PIXELFORMAT_RGB555 
SDL_PIXELFORMAT_XBGR1555 
SDL_PIXELFORMAT_BGR555 
SDL_PIXELFORMAT_ARGB4444 
SDL_PIXELFORMAT_RGBA4444 
SDL_PIXELFORMAT_ABGR4444 
SDL_PIXELFORMAT_BGRA4444 
SDL_PIXELFORMAT_ARGB1555 
SDL_PIXELFORMAT_RGBA5551 
SDL_PIXELFORMAT_ABGR1555 
SDL_PIXELFORMAT_BGRA5551 
SDL_PIXELFORMAT_RGB565 
SDL_PIXELFORMAT_BGR565 
SDL_PIXELFORMAT_RGB24 
SDL_PIXELFORMAT_BGR24 
SDL_PIXELFORMAT_XRGB8888 
SDL_PIXELFORMAT_RGBX8888 
SDL_PIXELFORMAT_XBGR8888 
SDL_PIXELFORMAT_BGRX8888 
SDL_PIXELFORMAT_ARGB8888 
SDL_PIXELFORMAT_RGBA8888 
SDL_PIXELFORMAT_ABGR8888 
SDL_PIXELFORMAT_BGRA8888 
SDL_PIXELFORMAT_XRGB2101010 
SDL_PIXELFORMAT_XBGR2101010 
SDL_PIXELFORMAT_ARGB2101010 
SDL_PIXELFORMAT_ABGR2101010 
SDL_PIXELFORMAT_RGBA32 
SDL_PIXELFORMAT_ARGB32 
SDL_PIXELFORMAT_BGRA32 
SDL_PIXELFORMAT_ABGR32 
SDL_PIXELFORMAT_RGBX32 
SDL_PIXELFORMAT_XRGB32 
SDL_PIXELFORMAT_BGRX32 
SDL_PIXELFORMAT_XBGR32 
SDL_PIXELFORMAT_YV12 

Planar mode: Y + V + U (3 planes)

SDL_PIXELFORMAT_IYUV 

Planar mode: Y + U + V (3 planes)

SDL_PIXELFORMAT_YUY2 

Packed mode: Y0+U0+Y1+V0 (1 plane)

SDL_PIXELFORMAT_UYVY 

Packed mode: U0+Y0+V0+Y1 (1 plane)

SDL_PIXELFORMAT_YVYU 

Packed mode: Y0+V0+Y1+U0 (1 plane)

SDL_PIXELFORMAT_NV12 

Planar mode: Y + U/V interleaved (2 planes)

SDL_PIXELFORMAT_NV21 

Planar mode: Y + V/U interleaved (2 planes)

SDL_PIXELFORMAT_EXTERNAL_OES 

Android video texture format

Definition at line 205 of file SDL_pixels.h.

206{
210 1, 0),
213 1, 0),
216 2, 0),
219 2, 0),
222 4, 0),
225 4, 0),
233 SDL_PACKEDLAYOUT_4444, 12, 2),
237 SDL_PACKEDLAYOUT_4444, 12, 2),
241 SDL_PACKEDLAYOUT_1555, 15, 2),
245 SDL_PACKEDLAYOUT_1555, 15, 2),
249 SDL_PACKEDLAYOUT_4444, 16, 2),
252 SDL_PACKEDLAYOUT_4444, 16, 2),
255 SDL_PACKEDLAYOUT_4444, 16, 2),
258 SDL_PACKEDLAYOUT_4444, 16, 2),
261 SDL_PACKEDLAYOUT_1555, 16, 2),
264 SDL_PACKEDLAYOUT_5551, 16, 2),
267 SDL_PACKEDLAYOUT_1555, 16, 2),
270 SDL_PACKEDLAYOUT_5551, 16, 2),
273 SDL_PACKEDLAYOUT_565, 16, 2),
276 SDL_PACKEDLAYOUT_565, 16, 2),
279 24, 3),
282 24, 3),
285 SDL_PACKEDLAYOUT_8888, 24, 4),
288 SDL_PACKEDLAYOUT_8888, 24, 4),
291 SDL_PACKEDLAYOUT_8888, 24, 4),
294 SDL_PACKEDLAYOUT_8888, 24, 4),
297 SDL_PACKEDLAYOUT_8888, 32, 4),
300 SDL_PACKEDLAYOUT_8888, 32, 4),
303 SDL_PACKEDLAYOUT_8888, 32, 4),
306 SDL_PACKEDLAYOUT_8888, 32, 4),
319
320 /* Aliases for RGBA byte arrays of color data, for the current platform */
321#if SDL_BYTEORDER == SDL_BIG_ENDIAN
330#else
339#endif
340
341 SDL_PIXELFORMAT_YV12 = /**< Planar mode: Y + V + U (3 planes) */
342 SDL_DEFINE_PIXELFOURCC('Y', 'V', '1', '2'),
343 SDL_PIXELFORMAT_IYUV = /**< Planar mode: Y + U + V (3 planes) */
344 SDL_DEFINE_PIXELFOURCC('I', 'Y', 'U', 'V'),
345 SDL_PIXELFORMAT_YUY2 = /**< Packed mode: Y0+U0+Y1+V0 (1 plane) */
346 SDL_DEFINE_PIXELFOURCC('Y', 'U', 'Y', '2'),
347 SDL_PIXELFORMAT_UYVY = /**< Packed mode: U0+Y0+V0+Y1 (1 plane) */
348 SDL_DEFINE_PIXELFOURCC('U', 'Y', 'V', 'Y'),
349 SDL_PIXELFORMAT_YVYU = /**< Packed mode: Y0+V0+Y1+U0 (1 plane) */
350 SDL_DEFINE_PIXELFOURCC('Y', 'V', 'Y', 'U'),
351 SDL_PIXELFORMAT_NV12 = /**< Planar mode: Y + U/V interleaved (2 planes) */
352 SDL_DEFINE_PIXELFOURCC('N', 'V', '1', '2'),
353 SDL_PIXELFORMAT_NV21 = /**< Planar mode: Y + V/U interleaved (2 planes) */
354 SDL_DEFINE_PIXELFOURCC('N', 'V', '2', '1'),
355 SDL_PIXELFORMAT_EXTERNAL_OES = /**< Android video texture format */
356 SDL_DEFINE_PIXELFOURCC('O', 'E', 'S', ' ')
#define SDL_DEFINE_PIXELFOURCC(A, B, C, D)
Definition SDL_pixels.h:151
SDL_PixelFormatEnum
Definition SDL_pixels.h:206
@ SDL_PIXELFORMAT_BGR565
Definition SDL_pixels.h:274
@ SDL_PIXELFORMAT_EXTERNAL_OES
Definition SDL_pixels.h:355
@ SDL_PIXELFORMAT_RGB332
Definition SDL_pixels.h:228
@ SDL_PIXELFORMAT_INDEX2LSB
Definition SDL_pixels.h:214
@ SDL_PIXELFORMAT_INDEX1LSB
Definition SDL_pixels.h:208
@ SDL_PIXELFORMAT_BGR444
Definition SDL_pixels.h:238
@ SDL_PIXELFORMAT_RGBX32
Definition SDL_pixels.h:326
@ SDL_PIXELFORMAT_ABGR4444
Definition SDL_pixels.h:253
@ SDL_PIXELFORMAT_BGRA4444
Definition SDL_pixels.h:256
@ SDL_PIXELFORMAT_BGR24
Definition SDL_pixels.h:280
@ SDL_PIXELFORMAT_INDEX4MSB
Definition SDL_pixels.h:223
@ SDL_PIXELFORMAT_ABGR2101010
Definition SDL_pixels.h:316
@ SDL_PIXELFORMAT_BGRA32
Definition SDL_pixels.h:324
@ SDL_PIXELFORMAT_RGB555
Definition SDL_pixels.h:242
@ SDL_PIXELFORMAT_RGB444
Definition SDL_pixels.h:234
@ SDL_PIXELFORMAT_XBGR2101010
Definition SDL_pixels.h:310
@ SDL_PIXELFORMAT_INDEX2MSB
Definition SDL_pixels.h:217
@ SDL_PIXELFORMAT_RGBA8888
Definition SDL_pixels.h:298
@ SDL_PIXELFORMAT_RGBA5551
Definition SDL_pixels.h:262
@ SDL_PIXELFORMAT_ARGB1555
Definition SDL_pixels.h:259
@ SDL_PIXELFORMAT_XBGR4444
Definition SDL_pixels.h:235
@ SDL_PIXELFORMAT_INDEX8
Definition SDL_pixels.h:226
@ SDL_PIXELFORMAT_XRGB2101010
Definition SDL_pixels.h:307
@ SDL_PIXELFORMAT_XRGB8888
Definition SDL_pixels.h:283
@ SDL_PIXELFORMAT_BGRX32
Definition SDL_pixels.h:328
@ SDL_PIXELFORMAT_YV12
Definition SDL_pixels.h:341
@ SDL_PIXELFORMAT_ABGR32
Definition SDL_pixels.h:325
@ SDL_PIXELFORMAT_BGRX8888
Definition SDL_pixels.h:292
@ SDL_PIXELFORMAT_RGB24
Definition SDL_pixels.h:277
@ SDL_PIXELFORMAT_ABGR8888
Definition SDL_pixels.h:301
@ SDL_PIXELFORMAT_XBGR32
Definition SDL_pixels.h:329
@ SDL_PIXELFORMAT_NV12
Definition SDL_pixels.h:351
@ SDL_PIXELFORMAT_BGRA8888
Definition SDL_pixels.h:304
@ SDL_PIXELFORMAT_ARGB32
Definition SDL_pixels.h:323
@ SDL_PIXELFORMAT_ABGR1555
Definition SDL_pixels.h:265
@ SDL_PIXELFORMAT_NV21
Definition SDL_pixels.h:353
@ SDL_PIXELFORMAT_IYUV
Definition SDL_pixels.h:343
@ SDL_PIXELFORMAT_ARGB8888
Definition SDL_pixels.h:295
@ SDL_PIXELFORMAT_XRGB32
Definition SDL_pixels.h:327
@ SDL_PIXELFORMAT_XBGR1555
Definition SDL_pixels.h:243
@ SDL_PIXELFORMAT_XRGB4444
Definition SDL_pixels.h:231
@ SDL_PIXELFORMAT_ARGB4444
Definition SDL_pixels.h:247
@ SDL_PIXELFORMAT_RGBA32
Definition SDL_pixels.h:322
@ SDL_PIXELFORMAT_INDEX1MSB
Definition SDL_pixels.h:211
@ SDL_PIXELFORMAT_INDEX4LSB
Definition SDL_pixels.h:220
@ SDL_PIXELFORMAT_RGBX8888
Definition SDL_pixels.h:286
@ SDL_PIXELFORMAT_BGRA5551
Definition SDL_pixels.h:268
@ SDL_PIXELFORMAT_XRGB1555
Definition SDL_pixels.h:239
@ SDL_PIXELFORMAT_RGB565
Definition SDL_pixels.h:271
@ SDL_PIXELFORMAT_XBGR8888
Definition SDL_pixels.h:289
@ SDL_PIXELFORMAT_ARGB2101010
Definition SDL_pixels.h:313
@ SDL_PIXELFORMAT_BGR555
Definition SDL_pixels.h:246
@ SDL_PIXELFORMAT_UNKNOWN
Definition SDL_pixels.h:207
@ SDL_PIXELFORMAT_RGBA4444
Definition SDL_pixels.h:250
#define SDL_DEFINE_PIXELFORMAT(type, order, layout, bits, bytes)
Definition SDL_pixels.h:153

◆ SDL_PixelType

Pixel type.

Enumerator
SDL_PIXELTYPE_UNKNOWN 
SDL_PIXELTYPE_INDEX1 
SDL_PIXELTYPE_INDEX4 
SDL_PIXELTYPE_INDEX8 
SDL_PIXELTYPE_PACKED8 
SDL_PIXELTYPE_PACKED16 
SDL_PIXELTYPE_PACKED32 
SDL_PIXELTYPE_ARRAYU8 
SDL_PIXELTYPE_ARRAYU16 
SDL_PIXELTYPE_ARRAYU32 
SDL_PIXELTYPE_ARRAYF16 
SDL_PIXELTYPE_ARRAYF32 
SDL_PIXELTYPE_INDEX2 

Definition at line 87 of file SDL_pixels.h.

Function Documentation

◆ SDL_CreatePalette()

SDL_Palette * SDL_CreatePalette ( int  ncolors)
extern

Create a palette structure with the specified number of color entries.

The palette entries are initialized to white.

Parameters
ncolorsrepresents the number of color entries in the color palette
Returns
a new SDL_Palette structure on success or NULL on failure (e.g. if there wasn't enough memory); call SDL_GetError() for more information.
Since
This function is available since SDL 3.0.0.
See also
SDL_DestroyPalette

◆ SDL_CreatePixelFormat()

SDL_PixelFormat * SDL_CreatePixelFormat ( Uint32  pixel_format)
extern

Create an SDL_PixelFormat structure corresponding to a pixel format.

Returned structure may come from a shared global cache (i.e. not newly allocated), and hence should not be modified, especially the palette. Weird errors such as Blit combination not supported may occur.

Parameters
pixel_formatone of the SDL_PixelFormatEnum values
Returns
the new SDL_PixelFormat structure or NULL on failure; call SDL_GetError() for more information.
Since
This function is available since SDL 3.0.0.
See also
SDL_DestroyPixelFormat

◆ SDL_DestroyPalette()

void SDL_DestroyPalette ( SDL_Palette palette)
extern

Free a palette created with SDL_CreatePalette().

Parameters
palettethe SDL_Palette structure to be freed
Since
This function is available since SDL 3.0.0.
See also
SDL_CreatePalette

◆ SDL_DestroyPixelFormat()

void SDL_DestroyPixelFormat ( SDL_PixelFormat format)
extern

Free an SDL_PixelFormat structure allocated by SDL_CreatePixelFormat().

Parameters
formatthe SDL_PixelFormat structure to free
Since
This function is available since SDL 3.0.0.
See also
SDL_CreatePixelFormat

◆ SDL_GetMasksForPixelFormatEnum()

SDL_bool SDL_GetMasksForPixelFormatEnum ( Uint32  format,
int *  bpp,
Uint32 Rmask,
Uint32 Gmask,
Uint32 Bmask,
Uint32 Amask 
)
extern

Convert one of the enumerated pixel formats to a bpp value and RGBA masks.

Parameters
formatone of the SDL_PixelFormatEnum values
bppa bits per pixel value; usually 15, 16, or 32
Rmaska pointer filled in with the red mask for the format
Gmaska pointer filled in with the green mask for the format
Bmaska pointer filled in with the blue mask for the format
Amaska pointer filled in with the alpha mask for the format
Returns
SDL_TRUE on success or SDL_FALSE if the conversion wasn't possible; call SDL_GetError() for more information.
Since
This function is available since SDL 3.0.0.
See also
SDL_GetPixelFormatEnumForMasks

◆ SDL_GetPixelFormatEnumForMasks()

Uint32 SDL_GetPixelFormatEnumForMasks ( int  bpp,
Uint32  Rmask,
Uint32  Gmask,
Uint32  Bmask,
Uint32  Amask 
)
extern

Convert a bpp value and RGBA masks to an enumerated pixel format.

This will return SDL_PIXELFORMAT_UNKNOWN if the conversion wasn't possible.

Parameters
bppa bits per pixel value; usually 15, 16, or 32
Rmaskthe red mask for the format
Gmaskthe green mask for the format
Bmaskthe blue mask for the format
Amaskthe alpha mask for the format
Returns
one of the SDL_PixelFormatEnum values
Since
This function is available since SDL 3.0.0.
See also
SDL_GetMasksForPixelFormatEnum

◆ SDL_GetPixelFormatName()

const char * SDL_GetPixelFormatName ( Uint32  format)
extern

Get the human readable name of a pixel format.

Parameters
formatthe pixel format to query
Returns
the human readable name of the specified pixel format or SDL_PIXELFORMAT_UNKNOWN if the format isn't recognized.
Since
This function is available since SDL 3.0.0.

◆ SDL_GetRGB()

void SDL_GetRGB ( Uint32  pixel,
const SDL_PixelFormat format,
Uint8 r,
Uint8 g,
Uint8 b 
)
extern

Get RGB values from a pixel in the specified format.

This function uses the entire 8-bit [0..255] range when converting color components from pixel formats with less than 8-bits per RGB component (e.g., a completely white pixel in 16-bit RGB565 format would return [0xff, 0xff, 0xff] not [0xf8, 0xfc, 0xf8]).

Parameters
pixela pixel value
formatan SDL_PixelFormat structure describing the format of the pixel
ra pointer filled in with the red component
ga pointer filled in with the green component
ba pointer filled in with the blue component
Since
This function is available since SDL 3.0.0.
See also
SDL_GetRGBA
SDL_MapRGB
SDL_MapRGBA

◆ SDL_GetRGBA()

void SDL_GetRGBA ( Uint32  pixel,
const SDL_PixelFormat format,
Uint8 r,
Uint8 g,
Uint8 b,
Uint8 a 
)
extern

Get RGBA values from a pixel in the specified format.

This function uses the entire 8-bit [0..255] range when converting color components from pixel formats with less than 8-bits per RGB component (e.g., a completely white pixel in 16-bit RGB565 format would return [0xff, 0xff, 0xff] not [0xf8, 0xfc, 0xf8]).

If the surface has no alpha component, the alpha will be returned as 0xff (100% opaque).

Parameters
pixela pixel value
formatan SDL_PixelFormat structure describing the format of the pixel
ra pointer filled in with the red component
ga pointer filled in with the green component
ba pointer filled in with the blue component
aa pointer filled in with the alpha component
Since
This function is available since SDL 3.0.0.
See also
SDL_GetRGB
SDL_MapRGB
SDL_MapRGBA

◆ SDL_MapRGB()

Uint32 SDL_MapRGB ( const SDL_PixelFormat format,
Uint8  r,
Uint8  g,
Uint8  b 
)
extern

Map an RGB triple to an opaque pixel value for a given pixel format.

This function maps the RGB color value to the specified pixel format and returns the pixel value best approximating the given RGB color value for the given pixel format.

If the format has a palette (8-bit) the index of the closest matching color in the palette will be returned.

If the specified pixel format has an alpha component it will be returned as all 1 bits (fully opaque).

If the pixel format bpp (color depth) is less than 32-bpp then the unused upper bits of the return value can safely be ignored (e.g., with a 16-bpp format the return value can be assigned to a Uint16, and similarly a Uint8 for an 8-bpp format).

Parameters
formatan SDL_PixelFormat structure describing the pixel format
rthe red component of the pixel in the range 0-255
gthe green component of the pixel in the range 0-255
bthe blue component of the pixel in the range 0-255
Returns
a pixel value
Since
This function is available since SDL 3.0.0.
See also
SDL_GetRGB
SDL_GetRGBA
SDL_MapRGBA

◆ SDL_MapRGBA()

Uint32 SDL_MapRGBA ( const SDL_PixelFormat format,
Uint8  r,
Uint8  g,
Uint8  b,
Uint8  a 
)
extern

Map an RGBA quadruple to a pixel value for a given pixel format.

This function maps the RGBA color value to the specified pixel format and returns the pixel value best approximating the given RGBA color value for the given pixel format.

If the specified pixel format has no alpha component the alpha value will be ignored (as it will be in formats with a palette).

If the format has a palette (8-bit) the index of the closest matching color in the palette will be returned.

If the pixel format bpp (color depth) is less than 32-bpp then the unused upper bits of the return value can safely be ignored (e.g., with a 16-bpp format the return value can be assigned to a Uint16, and similarly a Uint8 for an 8-bpp format).

Parameters
formatan SDL_PixelFormat structure describing the format of the pixel
rthe red component of the pixel in the range 0-255
gthe green component of the pixel in the range 0-255
bthe blue component of the pixel in the range 0-255
athe alpha component of the pixel in the range 0-255
Returns
a pixel value
Since
This function is available since SDL 3.0.0.
See also
SDL_GetRGB
SDL_GetRGBA
SDL_MapRGB

◆ SDL_SetPaletteColors()

int SDL_SetPaletteColors ( SDL_Palette palette,
const SDL_Color colors,
int  firstcolor,
int  ncolors 
)
extern

Set a range of colors in a palette.

Parameters
palettethe SDL_Palette structure to modify
colorsan array of SDL_Color structures to copy into the palette
firstcolorthe index of the first palette entry to modify
ncolorsthe number of entries to modify
Returns
0 on success or a negative error code on failure; call SDL_GetError() for more information.
Since
This function is available since SDL 3.0.0.
See also
SDL_CreatePalette
SDL_CreateSurface

◆ SDL_SetPixelFormatPalette()

int SDL_SetPixelFormatPalette ( SDL_PixelFormat format,
SDL_Palette palette 
)
extern

Set the palette for a pixel format structure.

Parameters
formatthe SDL_PixelFormat structure that will use the palette
palettethe SDL_Palette structure that will be used
Returns
0 on success or a negative error code on failure; call SDL_GetError() for more information.
Since
This function is available since SDL 3.0.0.
See also
SDL_CreatePalette
SDL_DestroyPalette