Skip to content

TSdlPixelFormat

Pixel format.

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

Unit: Neslib.Sdl3.Video

type TSdlPixelFormat = (Unknown, Index1Lsb, Index1Msb, Index2Lsb, Index2Msb, Index4Lsb, Index4Msb, Index8, Rgb332, Xrgb4444, Xbgr4444, Xrgb1555, Xbgr1555, Argb4444, Rgba4444...)

Enumeration Values

Unknown = SDL_PIXELFORMAT_UNKNOWN


Index1Lsb = SDL_PIXELFORMAT_INDEX1LSB


Index1Msb = SDL_PIXELFORMAT_INDEX1MSB


Index2Lsb = SDL_PIXELFORMAT_INDEX2LSB


Index2Msb = SDL_PIXELFORMAT_INDEX2MSB


Index4Lsb = SDL_PIXELFORMAT_INDEX4LSB


Index4Msb = SDL_PIXELFORMAT_INDEX4MSB


Index8 = SDL_PIXELFORMAT_INDEX8


Rgb332 = SDL_PIXELFORMAT_RGB332


Xrgb4444 = SDL_PIXELFORMAT_XRGB4444


Xbgr4444 = SDL_PIXELFORMAT_XBGR4444


Xrgb1555 = SDL_PIXELFORMAT_XRGB1555


Xbgr1555 = SDL_PIXELFORMAT_XBGR1555


Argb4444 = SDL_PIXELFORMAT_ARGB4444


Rgba4444 = SDL_PIXELFORMAT_RGBA4444


Abgr4444 = SDL_PIXELFORMAT_ABGR4444


Bgra4444 = SDL_PIXELFORMAT_BGRA4444


Argb1555 = SDL_PIXELFORMAT_ARGB1555


Rgba5551 = SDL_PIXELFORMAT_RGBA5551


Abgr1555 = SDL_PIXELFORMAT_ABGR1555


Bgra5551 = SDL_PIXELFORMAT_BGRA5551


Rgb565 = SDL_PIXELFORMAT_RGB565


Bgr565 = SDL_PIXELFORMAT_BGR565


Rgb24 = SDL_PIXELFORMAT_RGB24


Bgr24 = SDL_PIXELFORMAT_BGR24


Xrgb8888 = SDL_PIXELFORMAT_XRGB8888


Rgbx8888 = SDL_PIXELFORMAT_RGBX8888


Xbgr8888 = SDL_PIXELFORMAT_XBGR8888


Bgrx8888 = SDL_PIXELFORMAT_BGRX8888


Argb8888 = SDL_PIXELFORMAT_ARGB8888


Rgba8888 = SDL_PIXELFORMAT_RGBA8888


Abgr8888 = SDL_PIXELFORMAT_ABGR8888


Bgra8888 = SDL_PIXELFORMAT_BGRA8888


Xrgb2101010 = SDL_PIXELFORMAT_XRGB2101010


Xbgr2101010 = SDL_PIXELFORMAT_XBGR2101010


Argb2101010 = SDL_PIXELFORMAT_ARGB2101010


Abgr2101010 = SDL_PIXELFORMAT_ABGR2101010


Rgb48 = SDL_PIXELFORMAT_RGB48


Bgr48 = SDL_PIXELFORMAT_BGR48


Rgba64 = SDL_PIXELFORMAT_RGBA64


Argb64 = SDL_PIXELFORMAT_ARGB64


Bgra64 = SDL_PIXELFORMAT_BGRA64


Abgr64 = SDL_PIXELFORMAT_ABGR64


Rgb48Float = SDL_PIXELFORMAT_RGB48_FLOAT


Bgr48Float = SDL_PIXELFORMAT_BGR48_FLOAT


Rgba64Float = SDL_PIXELFORMAT_RGBA64_FLOAT


Argb64Float = SDL_PIXELFORMAT_ARGB64_FLOAT


Bgra64Float = SDL_PIXELFORMAT_BGRA64_FLOAT


Abgr64Float = SDL_PIXELFORMAT_ABGR64_FLOAT


Rgb96Float = SDL_PIXELFORMAT_RGB96_FLOAT


Bgr96Float = SDL_PIXELFORMAT_BGR96_FLOAT


Rgba128Float = SDL_PIXELFORMAT_RGBA128_FLOAT


Argb128Float = SDL_PIXELFORMAT_ARGB128_FLOAT


Bgra128Float = SDL_PIXELFORMAT_BGRA128_FLOAT


Abgr128Float = SDL_PIXELFORMAT_ABGR128_FLOAT


Yv12 = SDL_PIXELFORMAT_YV12

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


Iyuv = SDL_PIXELFORMAT_IYUV

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


Yuy2 = SDL_PIXELFORMAT_YUY2

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


Uyvy = SDL_PIXELFORMAT_UYVY

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


Yvyu = SDL_PIXELFORMAT_YVYU

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


Nv12 = SDL_PIXELFORMAT_NV12

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


Nv21 = SDL_PIXELFORMAT_NV21

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


P010 = SDL_PIXELFORMAT_P010

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


ExternalOes = SDL_PIXELFORMAT_EXTERNAL_OES

Android video texture format


Mjpg = SDL_PIXELFORMAT_MJPG

Motion JPOEG


Rgba32 = SDL_PIXELFORMAT_RGBA32


Argb32 = SDL_PIXELFORMAT_ARGB32


Bgra32 = SDL_PIXELFORMAT_BGRA32


Abgr32 = SDL_PIXELFORMAT_ABGR32


Rgbx32 = SDL_PIXELFORMAT_RGBX32


Xrgb32 = SDL_PIXELFORMAT_XRGB32


Bgrx32 = SDL_PIXELFORMAT_BGRX32


Xbgr32 = SDL_PIXELFORMAT_XBGR32


Properties

Name Description
ArrayOrder The array order of this pixel format or None if it isn't applicable.
BitmapOrder The bitmap order of this pixel format or None if it isn't applicable.
BitsPerPixel The format's bits per pixel.
BytesPerPixel The format's bytes per pixel.
Details The details of this pixel format.
HasAlpha Whether this format has an alpha channel.
Is10Bit Whether this is a 10-bit format.
IsArray Whether this is an array format.
IsFloat Whether this is a floating-point format.
IsFourCC Whether this is a "FourCC format. This covers custom and other unusual formats.
IsIndexed Whether this is an indexed format.
IsPacked Whether this is a packed format.
Layout The layout of this pixel format or None if it isn't applicable.
Name The human readable name of this pixel format, or 'SDL_PIXELFORMAT_UNKNOWN' if the format isn't recognized.
PackedOrder The packed order of this pixel format or None if it isn't applicable.
PixelType The pixel type of this pixel format.

Methods

Name Description
From(Char, Char, Char, Char) Define a custom FourCC pixel format.
From(TSdlPixelType, TSdlBitmapOrder, TSdlPackedLayout, Integer, Integer) Define a custom non-FourCC pixel formats.
From(TSdlPixelType, TSdlPackedOrder, TSdlPackedLayout, Integer, Integer)
From(TSdlPixelType, TSdlArrayOrder, TSdlPackedLayout, Integer, Integer)
FromMasks Convert a bpp value and RGBA masks to a pixel format.
GetMasks Convert the pixel formats to a bpp value and RGBA masks.

Property Descriptions

ArrayOrder

The array order of this pixel format or None if it isn't applicable.

property ArrayOrder: TSdlArrayOrder read GetArrayOrder

Type: TSdlArrayOrder

Remarks

It is safe to call this from any thread.


BitmapOrder

The bitmap order of this pixel format or None if it isn't applicable.

property BitmapOrder: TSdlBitmapOrder read GetBitmapOrder

Type: TSdlBitmapOrder

Remarks

It is safe to call this from any thread.


BitsPerPixel

The format's bits per pixel.

FourCC formats will report zero here, as it rarely makes sense to measure them per-pixel.

property BitsPerPixel: Integer read GetBitsPerPixel

Type: Integer

Remarks

It is safe to call this from any thread.


BytesPerPixel

The format's bytes per pixel.

FourCC formats do their best here, but many of them don't have a meaningful measurement of bytes per pixel.

property BytesPerPixel: Integer read GetBytesPerPixel

Type: Integer

Remarks

It is safe to call this from any thread.


Details

The details of this pixel format.

property Details: TSdlPixelFormatDetails read GetDetails

Type: TSdlPixelFormatDetails

Exceptions

ESdlError: Raised on failure.

Remarks

It is safe to use this property from any thread.


HasAlpha

Whether this format has an alpha channel.

property HasAlpha: Boolean read GetHasAlpha

Type: Boolean

Remarks

It is safe to call this from any thread.


Is10Bit

Whether this is a 10-bit format.

property Is10Bit: Boolean read GetIs10Bit

Type: Boolean

Remarks

It is safe to call this from any thread.


IsArray

Whether this is an array format.

property IsArray: Boolean read GetIsArray

Type: Boolean

Remarks

It is safe to call this from any thread.


IsFloat

Whether this is a floating-point format.

property IsFloat: Boolean read GetIsFloat

Type: Boolean

Remarks

It is safe to call this from any thread.


IsFourCC

Whether this is a "FourCC format. This covers custom and other unusual formats.

property IsFourCC: Boolean read GetIsFourCC

Type: Boolean

Remarks

It is safe to call this from any thread.


IsIndexed

Whether this is an indexed format.

property IsIndexed: Boolean read GetIsIndexed

Type: Boolean

Remarks

It is safe to call this from any thread.


IsPacked

Whether this is a packed format.

property IsPacked: Boolean read GetIsPacked

Type: Boolean

Remarks

It is safe to call this from any thread.


Layout

The layout of this pixel format or None if it isn't applicable.

property Layout: TSdlPackedLayout read GetLayout

Type: TSdlPackedLayout

Remarks

It is safe to call this from any thread.


Name

The human readable name of this pixel format, or 'SDL_PIXELFORMAT_UNKNOWN' if the format isn't recognized.

property Name: String read GetName

Type: String

Remarks

It is safe to use this property from any thread.


PackedOrder

The packed order of this pixel format or None if it isn't applicable.

property PackedOrder: TSdlPackedOrder read GetPackedOrder

Type: TSdlPackedOrder

Remarks

It is safe to call this from any thread.


PixelType

The pixel type of this pixel format.

property PixelType: TSdlPixelType read GetPixelType

Type: TSdlPixelType

Remarks

It is safe to call this from any thread.


Method Descriptions

From(Char, Char, Char, Char)

Define a custom FourCC pixel format.

For example, defining TSdlPixelFormat.YV12 looks like this:

  var PixelFormat := TSdlPixelFormat.From('Y', 'V', '1', '2')

class function From(const AA, AB, AC, AD: Char): TSdlPixelFormat; overload; inline; static

Parameters

AA: Char : The first character of the FourCC code.

AB: Char : The second character of the FourCC code.

AC: Char : The third character of the FourCC code.

AD: Char : The fourth character of the FourCC code.

Returns

TSdlPixelFormat: The custom pixel format.

Remarks

It is safe to call this from any thread.


From(TSdlPixelType, TSdlBitmapOrder, TSdlPackedLayout, Integer, Integer)

Define a custom non-FourCC pixel formats.

For example, defining TSdlPixelFormat.Rgba8888 looks like this:

  var PixelFormat := TSdlPixelFormat.From(TSdlPixelType.Packed32,
    TSdlPackedOrder.Rgba, TSdlPackedLayout.Layout8888, 32, 4);

class function From(const AType: TSdlPixelType; const AOrder: TSdlBitmapOrder; const ALayout: TSdlPackedLayout; const ABits, ABytes: Integer): TSdlPixelFormat; overload; inline; static

Parameters

AType: TSdlPixelType : The type of the new format.

AOrder: TSdlBitmapOrder : The order of the new format (of type TSdlBitmapOrder, TSdlPackedOrder or TSdlArrayOrder).

ALayout: TSdlPackedLayout : The layout of the new format or None.

ABits: Integer : The number of bits per pixel of the new format.

ABytes: Integer : The number of bytes per pixel of the new format.

Returns

TSdlPixelFormat: The custom pixel format.

Remarks

It is safe to call this from any thread.


From(TSdlPixelType, TSdlPackedOrder, TSdlPackedLayout, Integer, Integer)

class function From(const AType: TSdlPixelType; const AOrder: TSdlPackedOrder; const ALayout: TSdlPackedLayout; const ABits, ABytes: Integer): TSdlPixelFormat; overload; inline; static

Parameters

AType: TSdlPixelType

AOrder: TSdlPackedOrder

ALayout: TSdlPackedLayout

ABits: Integer

ABytes: Integer

Returns

TSdlPixelFormat


From(TSdlPixelType, TSdlArrayOrder, TSdlPackedLayout, Integer, Integer)

class function From(const AType: TSdlPixelType; const AOrder: TSdlArrayOrder; const ALayout: TSdlPackedLayout; const ABits, ABytes: Integer): TSdlPixelFormat; overload; inline; static

Parameters

AType: TSdlPixelType

AOrder: TSdlArrayOrder

ALayout: TSdlPackedLayout

ABits: Integer

ABytes: Integer

Returns

TSdlPixelFormat


FromMasks(Integer, Cardinal, Cardinal, Cardinal, Cardinal)

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

This will return TSdlPixelFormat.Unknown if the conversion wasn't possible.

class function FromMasks(const ABpp: Integer; const ARMask, AGMask, ABMask, AAMask: Cardinal): TSdlPixelFormat; inline; static

Parameters

ABpp: Integer : A bits per pixel value; usually 15, 16, or 32.

ARMask: Cardinal : The red mask for the format.

AGMask: Cardinal : The green mask for the format.

ABMask: Cardinal : The blue mask for the format.

AAMask: Cardinal : The alpha mask for the format.

Returns

TSdlPixelFormat: The pixel format corresponding to the format masks, or TSdlPixelFormat.Unknown if there isn't a match.

See Also

Remarks

It is safe to call this function method any thread.


GetMasks(Integer, Cardinal, Cardinal, Cardinal, Cardinal)

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

procedure GetMasks(out ABpp: Integer; out ARMask, AGMask, ABMask, AAMask: Cardinal); inline

Exceptions

ESdlError: Raised on failure.

Parameters

ABpp: Integer : Is set to the bits per pixel value; usually 15, 16, or 32.

ARMask: Cardinal : Is set to the red mask for the format.

AGMask: Cardinal : Is set to the green mask for the format.

ABMask: Cardinal : Is set to the blue mask for the format.

AAMask: Cardinal : Is set to the alpha mask for the format.

See Also

Remarks

It is safe to call this method from any thread.