Class PixelFormat
D class that wraps SDL_PixelFormat
defining the color and alpha channel bit layout in the internal
representation of a pixel
class PixelFormat
;
Constructors
Name | Description |
---|---|
this
(sdlPixelFormat, isOwner, userRef)
|
Constructs a dsdl2 from a vanilla SDL_PixelFormat* from bindbc-sdl
|
this
(sdlPixelFormatEnum)
|
Constructs a dsdl2 using an SDL_PixelFormatEnum from bindbc-sdl
|
this
(sdlPixelFormatEnum, palette)
|
Constructs a dsdl2 using an indexed SDL_PixelFormatEnum from bindbc-sdl, allowing use with
dsdl2 s
|
this
(bitsPerPixel, rgbaMasks)
|
Constructs a dsdl2 from user-provided bit masks for RGB color and alpha channels by internally
using SDL_MasksToPixelFormatEnum to retrieve the SDL_PixelFormatEnum
|
Fields
Name | Type | Description |
---|---|---|
sdlPixelFormat
|
sdl | Internal SDL_PixelFormat pointer
|
Properties
Name | Type | Description |
---|---|---|
bitsPerPixel [get]
|
ubyte | Gets the bit depth (size of a pixel in bits) of the dsdl2
|
bytesPerPixel [get]
|
ulong | Gets the how many bytes needed to represent a pixel in the dsdl2
|
fourCC [get]
|
bool | Wraps SDL_ISPIXELFORMAT_FOURCC which checks whether the dsdl2 represents a unique format
|
hasAlpha [get]
|
bool | Wraps SDL_ISPIXELFORMAT_ALPHA which checks whether the dsdl2 is capable of storing alpha value
|
indexed [get]
|
bool | Wraps SDL_ISPIXELFORMAT_INDEXED which checks whether the dsdl2 is indexed
|
palette [get]
|
inout(Palette) | Gets the dsdl2 bounds to the indexed dsdl2
|
palette [set]
|
Palette | Wraps SDL_SetPixelFormatPalette which sets the dsdl2 for indexed dsdl2 s`
|
sdlPixelFormatEnum [get]
|
uint | Gets the SDL_PixelFormatEnum of the underlying SDL_PixelFormat
|
Methods
Name | Description |
---|---|
getRGB
(pixel)
|
Wraps SDL_GetRGB which converts a pixel uint value to a comprehensible dsdl2 struct without
accounting the alpha value (automatically set to opaque [255]), based on the pixel format defined by the
dsdl2
|
getRGBA
(pixel)
|
Wraps SDL_GetRGBA which converts a pixel uint value to a comprehensible dsdl2 struct, based on
the pixel format defined by the dsdl2
|
mapRGB
(color)
|
Wraps SDL_MapRGB which converts a dsdl2 to its pixel uint value according to the pixel format
defined by the dsdl2 without accounting the alpha value, assuming that it's opaque
|
mapRGBA
(color)
|
Wraps SDL_MapRGBA which converts a dsdl2 to its pixel uint value according to the pixel format
defined by the dsdl2
|
opEquals
(rhs)
|
Equality operator overload |
toHash
()
|
Gets the hash of the dsdl2
|
toMasks
()
|
Wraps SDL_PixelFormatEnumToMasks which gets the bit mask for all four channels of the dsdl2
|
toString
()
|
Formats the dsdl2 into its construction representation:
"dsdl2.PixelFormat(<sdlPixelFormatEnum>)" or "dsdl2.PixelFormat(<sdlPixelFormatEnum>, <palette>)"
|
Aliases
Name | Description |
---|---|
abgr1555
|
Retrieves one of the dsdl2 multiton presets from SDL_PIXELFORMAT_* enumeration constants
|
abgr32
|
Retrieves one of the dsdl2 multiton presets from SDL_PIXELFORMAT_* enumeration constants
(from SDL 2.0.5)
|
abgr4444
|
Retrieves one of the dsdl2 multiton presets from SDL_PIXELFORMAT_* enumeration constants
|
abgr8888
|
Retrieves one of the dsdl2 multiton presets from SDL_PIXELFORMAT_* enumeration constants
|
argb1555
|
Retrieves one of the dsdl2 multiton presets from SDL_PIXELFORMAT_* enumeration constants
|
argb2101010
|
Retrieves one of the dsdl2 multiton presets from SDL_PIXELFORMAT_* enumeration constants
|
argb32
|
Retrieves one of the dsdl2 multiton presets from SDL_PIXELFORMAT_* enumeration constants
(from SDL 2.0.5)
|
argb4444
|
Retrieves one of the dsdl2 multiton presets from SDL_PIXELFORMAT_* enumeration constants
|
argb8888
|
Retrieves one of the dsdl2 multiton presets from SDL_PIXELFORMAT_* enumeration constants
|
bgr24
|
Retrieves one of the dsdl2 multiton presets from SDL_PIXELFORMAT_* enumeration constants
|
bgr555
|
Retrieves one of the dsdl2 multiton presets from SDL_PIXELFORMAT_* enumeration constants
|
bgr565
|
Retrieves one of the dsdl2 multiton presets from SDL_PIXELFORMAT_* enumeration constants
|
bgr888
|
Retrieves one of the dsdl2 multiton presets from SDL_PIXELFORMAT_* enumeration constants
|
bgra32
|
Retrieves one of the dsdl2 multiton presets from SDL_PIXELFORMAT_* enumeration constants
(from SDL 2.0.5)
|
bgra4444
|
Retrieves one of the dsdl2 multiton presets from SDL_PIXELFORMAT_* enumeration constants
|
bgra5551
|
Retrieves one of the dsdl2 multiton presets from SDL_PIXELFORMAT_* enumeration constants
|
bgra8888
|
Retrieves one of the dsdl2 multiton presets from SDL_PIXELFORMAT_* enumeration constants
|
bgrx8888
|
Retrieves one of the dsdl2 multiton presets from SDL_PIXELFORMAT_* enumeration constants
|
index1lsb
|
Instantiates indexed dsdl2 for use with dsdl2 s from SDL_PIXELFORMAT_* enumeration
constants
|
index1msb
|
Instantiates indexed dsdl2 for use with dsdl2 s from SDL_PIXELFORMAT_* enumeration
constants
|
index4lsb
|
Instantiates indexed dsdl2 for use with dsdl2 s from SDL_PIXELFORMAT_* enumeration
constants
|
index4msb
|
Instantiates indexed dsdl2 for use with dsdl2 s from SDL_PIXELFORMAT_* enumeration
constants
|
index8
|
Instantiates indexed dsdl2 for use with dsdl2 s from SDL_PIXELFORMAT_* enumeration
constants
|
iyuv
|
Retrieves one of the dsdl2 multiton presets from SDL_PIXELFORMAT_* enumeration constants
|
nv12
|
Instantiates indexed dsdl2 for use with dsdl2 s from SDL_PIXELFORMAT_*
enumeration constants (from SDL 2.0.4)
|
nv21
|
Instantiates indexed dsdl2 for use with dsdl2 s from SDL_PIXELFORMAT_*
enumeration constants (from SDL 2.0.4)
|
rgb24
|
Retrieves one of the dsdl2 multiton presets from SDL_PIXELFORMAT_* enumeration constants
|
rgb332
|
Retrieves one of the dsdl2 multiton presets from SDL_PIXELFORMAT_* enumeration constants
|
rgb444
|
Retrieves one of the dsdl2 multiton presets from SDL_PIXELFORMAT_* enumeration constants
|
rgb555
|
Retrieves one of the dsdl2 multiton presets from SDL_PIXELFORMAT_* enumeration constants
|
rgb565
|
Retrieves one of the dsdl2 multiton presets from SDL_PIXELFORMAT_* enumeration constants
|
rgb888
|
Retrieves one of the dsdl2 multiton presets from SDL_PIXELFORMAT_* enumeration constants
|
rgba32
|
Retrieves one of the dsdl2 multiton presets from SDL_PIXELFORMAT_* enumeration constants
(from SDL 2.0.5)
|
rgba444
|
Retrieves one of the dsdl2 multiton presets from SDL_PIXELFORMAT_* enumeration constants
|
rgba5551
|
Retrieves one of the dsdl2 multiton presets from SDL_PIXELFORMAT_* enumeration constants
|
rgba8888
|
Retrieves one of the dsdl2 multiton presets from SDL_PIXELFORMAT_* enumeration constants
|
rgbx8888
|
Retrieves one of the dsdl2 multiton presets from SDL_PIXELFORMAT_* enumeration constants
|
uyvy
|
Retrieves one of the dsdl2 multiton presets from SDL_PIXELFORMAT_* enumeration constants
|
yuy2
|
Instantiates indexed dsdl2 for use with dsdl2 s from SDL_PIXELFORMAT_* enumeration
constants
|
yv12
|
Instantiates indexed dsdl2 for use with dsdl2 s from SDL_PIXELFORMAT_* enumeration
constants
|
yvyu
|
Retrieves one of the dsdl2 multiton presets from SDL_PIXELFORMAT_* enumeration constants
|
Example
static if (sdlSupport >= SDLSupport .v2_0_5) {
const auto rgba32 = dsdl2 .PixelFormat .rgba32;
assert(rgba32 .mapRGBA(dsdl2 .Color(0x12, 0x34, 0x56, 0x78)) == 0x12345678);
assert(rgba32 .getRGBA(0x12345678) == dsdl2 .Color(0x12, 0x34, 0x56, 0x78));
}
const auto rgba8888 = dsdl2 .PixelFormat .rgba8888;
version (LittleEndian) {
assert(rgba8888 .mapRGBA(dsdl2 .Color(0x12, 0x34, 0x56, 0x78)) == 0x12345678);
assert(rgba8888 .getRGBA(0x12345678) == dsdl2 .Color(0x12, 0x34, 0x56, 0x78));
}
version (BigEndian) {
assert(rgba8888 .mapRGBA(dsdl2 .Color(0x12, 0x34, 0x56, 0x78)) == 0x78563412);
assert(rgba8888 .get(0x78563412) == dsdl2 .Color(0x12, 0x34, 0x56, 0x78));
}