SDL3pp
A slim C++ wrapper for SDL3
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
SDL::PixelFormat Class Reference

Pixel format. More...

Public Member Functions

constexpr PixelFormat (PixelFormatRaw format={})
 Wraps PixelFormat. More...
 
constexpr PixelFormat (PixelType type, int order, PackedLayout layout, int bits, int bytes)
 Defining custom non-FourCC pixel formats. More...
 
constexpr operator PixelFormatRaw () const
 Unwraps to the underlying PixelFormat. More...
 
constexpr Uint8 GetFlags () const
 Retrieve the flags of an PixelFormat. More...
 
constexpr PixelType GetType () const
 Retrieve the type. More...
 
constexpr int GetOrder () const
 Retrieve the order. More...
 
constexpr PackedLayout GetLayout () const
 Retrieve the layout. More...
 
constexpr int GetBitsPerPixel () const
 Determine this's bits per pixel. More...
 
constexpr int GetBytesPerPixel () const
 Determine this's bytes per pixel. More...
 
constexpr bool IsIndexed () const
 Determine if this is an indexed format. More...
 
constexpr bool IsPacked () const
 Determine if this is a packed format. More...
 
constexpr bool IsArray () const
 Determine if this is an array format. More...
 
constexpr bool Is10Bit () const
 Determine if this is a 10-bit format. More...
 
constexpr bool IsFloat () const
 Determine if this is a floating point format. More...
 
const char * GetName () const
 Get the human readable name of a pixel format. More...
 
void GetMasks (int *bpp, Uint32 *Rmask, Uint32 *Gmask, Uint32 *Bmask, Uint32 *Amask) const
 Convert one of the enumerated pixel formats to a bpp value and RGBA masks. More...
 
const PixelFormatDetailsGetDetails () const
 Create an PixelFormatDetails structure corresponding to a pixel format. More...
 
 operator const PixelFormatDetails & () const
 Same as GetDetails()
 
Uint32 Map (ColorRaw c, PaletteConstParam palette={}) const
 Map an RGBA quadruple to a pixel value for a given pixel format. More...
 
Color Get (Uint32 pixel, PaletteConstParam palette={}) const
 Get RGBA values from a pixel in the specified format. More...
 
ColorTypes
constexpr bool IsAlpha () const
 Determine if this has an alpha channel. More...
 
constexpr bool IsFourCC () const
 Determine if this is a "FourCC" format. More...
 

Static Public Member Functions

static PixelFormat ForMasks (int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
 Convert a bpp value and RGBA masks to an enumerated pixel format. More...
 

Detailed Description

SDL's pixel formats have the following naming convention:

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.

Since
This enum is available since SDL 3.2.0.
Category:
Wrap state
See also
wrap-state
PixelFormats

Constructor & Destructor Documentation

◆ PixelFormat() [1/2]

constexpr SDL::PixelFormat::PixelFormat ( PixelFormatRaw  format = {})
inlineconstexpr
Parameters
formatthe value to be wrapped

◆ PixelFormat() [2/2]

constexpr SDL::PixelFormat::PixelFormat ( PixelType  type,
int  order,
PackedLayout  layout,
int  bits,
int  bytes 
)
inlineconstexpr

For example, defining PIXELFORMAT_RGBA8888 looks like this:

Pixel format.
Definition: SDL3pp_pixels.h:408
constexpr PixelType PIXELTYPE_PACKED32
PACKED32.
Definition: SDL3pp_pixels.h:230
constexpr PackedOrder PACKEDORDER_RGBA
RGBA.
Definition: SDL3pp_pixels.h:286
constexpr PackedLayout PACKEDLAYOUT_8888
8888
Definition: SDL3pp_pixels.h:350
Parameters
typethe type of the new format, probably a PixelType value.
orderthe order of the new format, probably a BitmapOrder, PackedOrder, or ArrayOrder value.
layoutthe layout of the new format, probably an PackedLayout value or zero.
bitsthe number of bits per pixel of the new format.
bytesthe number of bytes per pixel of the new format.
Postcondition
a format value in the style of PixelFormat.
Thread safety:
It is safe to call this macro from any thread.
Since
This macro is available since SDL 3.2.0.

Member Function Documentation

◆ operator PixelFormatRaw()

constexpr SDL::PixelFormat::operator PixelFormatRaw ( ) const
inlineconstexpr
Returns
the underlying PixelFormatRaw.

The documentation for this class was generated from the following file: