|
constexpr | PixelFormat (SDL_PixelFormat format={}) |
| Wraps PixelFormat.
|
|
constexpr | PixelFormat (SDL_PixelType type, int order, SDL_PackedLayout layout, int bits, int bytes) |
| Defining custom non-FourCC pixel formats.
|
|
constexpr bool | operator== (const PixelFormat &other) const =default |
| Default comparison operator.
|
|
constexpr bool | operator== (SDL_PixelFormat format) const |
| Compares with the underlying type.
|
|
constexpr | operator SDL_PixelFormat () const |
| Unwraps to the underlying PixelFormat.
|
|
constexpr | operator bool () const |
| Check if valid.
|
|
constexpr PixelType | GetType () const |
| Retrieve the type.
|
|
constexpr int | GetOrder () const |
| Retrieve the order.
|
|
constexpr PackedLayout | GetLayout () const |
| Retrieve the layout.
|
|
constexpr int | GetBitsPerPixel () const |
| Determine this's bits per pixel.
|
|
constexpr int | GetBytesPerPixel () const |
| Determine this's bytes per pixel.
|
|
constexpr bool | IsIndexed () const |
| Determine if this is an indexed format.
|
|
constexpr bool | IsPacked () const |
| Determine if this is a packed format.
|
|
constexpr bool | IsArray () const |
| Determine if this is an array format.
|
|
constexpr bool | Is10Bit () const |
| Determine if this is a 10-bit format.
|
|
constexpr bool | IsFloat () const |
| Determine if this is a floating point format.
|
|
constexpr bool | IsAlpha () const |
| Determine if this has an alpha channel.
|
|
constexpr bool | IsFourCC () const |
| Determine if this is a "FourCC" format.
|
|
const char * | GetName () const |
| Get the human readable name of a pixel format.
|
|
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.
|
|
const PixelFormatDetails * | GetDetails () const |
| Create an PixelFormatDetails structure corresponding to a pixel format.
|
|
Uint32 | Map (Color color, PaletteRef palette) const |
| Map an RGBA quadruple to a pixel value for a given pixel format.
|
|
Color | Get (Uint32 pixel, PaletteRef palette) const |
| Get RGBA values from a pixel in the specified 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.
- Since
- This enum is available since SDL 3.2.0.
- Category:
- Wrap state
- See also
- wrap-state
-
PixelFormats
Color SDL::PixelFormat::Get |
( |
Uint32 |
pixel, |
|
|
PaletteRef |
palette = nullptr |
|
) |
| const |
|
inline |
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
-
pixel | a pixel value. |
palette | an optional palette for indexed formats, may be NULL. |
- Returns
- a color value.
- Thread safety:
- It is safe to call this function from any thread, as long as the palette is not modified.
- Since
- This function is available since SDL 3.2.0.
- See also
- GetPixelFormatDetails()
-
GetRGBA()
-
Map()
Uint32 SDL::PixelFormat::Map |
( |
Color |
color, |
|
|
PaletteRef |
palette = nullptr |
|
) |
| const |
|
inline |
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
-
color | the color components of the pixel in the range 0-255. |
palette | an optional palette for indexed formats, may be NULL. |
- Returns
- a pixel value.
- Thread safety:
- It is safe to call this function from any thread, as long as the palette is not modified.
- Since
- This function is available since SDL 3.2.0.
- See also
- GetPixelFormatDetails()
-
Get()
-
MapRGBA()
-
Surface.MapColor()