Module pixels
dep_sdl3
only.Expand description
SDL offers facilities for pixel management.
Largely these facilities deal with pixel format: what does this set of bits represent?
If you mostly want to think of a pixel as some combination of red, green, blue, and maybe alpha intensities, this is all pretty straightforward, and in many cases, is enough information to build a perfectly fine game.
However, the actual definition of a pixel is more complex than that:
Pixels are a representation of a color in a particular color space.
The first characteristic of a color space is the color type. SDL understands two different color types, RGB and YCbCr, or in SDL also referred to as YUV.
RGB colors consist of red, green, and blue channels of color that are added together to represent the colors we see on the screen.
https://en.wikipedia.org/wiki/RGB_color_model
YCbCr colors represent colors as a Y luma brightness component and red and blue chroma color offsets. This color representation takes advantage of the fact that the human eye is more sensitive to brightness than the color in an image. The Cb and Cr components are often compressed and have lower resolution than the luma component.
https://en.wikipedia.org/wiki/YCbCr
When the color information in YCbCr is compressed, the Y pixels are left at full resolution and each Cr and Cb pixel represents an average of the color information in a block of Y pixels. The chroma location determines where in that block of pixels the color information is coming from.
The color range defines how much of the pixel to use when converting a pixel into a color on the display. When the full color range is used, the entire numeric range of the pixel bits is significant. When narrow color range is used, for historical reasons, the pixel uses only a portion of the numeric range to represent colors.
The color primaries and white point are a definition of the colors in the color space relative to the standard XYZ color space.
https://en.wikipedia.org/wiki/CIE_1931_color_space
The transfer characteristic, or opto-electrical transfer function (OETF), is the way a color is converted from mathematically linear space into a non-linear output signals.
https://en.wikipedia.org/wiki/Rec._709#Transfer_characteristics
The matrix coefficients are used to convert between YCbCr and RGB colors.
Structs§
- SDL_
Array Order - Array component order, low byte -> high byte.
- SDL_
Bitmap Order - Bitmap pixel order, high bit -> low bit.
- SDL_
Chroma Location - Colorspace chroma sample location.
- SDL_
Color - A structure that represents a color as RGBA components.
- SDL_
Color Primaries - Colorspace color primaries, as described by https://www.itu.int/rec/T-REC-H.273-201612-S/en
- SDL_
Color Range - Colorspace color range, as described by https://www.itu.int/rec/R-REC-BT.2100-2-201807-I/en
- SDL_
Color Type - Colorspace color type.
- SDL_
Colorspace - Colorspace definitions.
- SDL_
FColor - The bits of this structure can be directly reinterpreted as a float-packed
color which uses the
SDL_PIXELFORMAT_RGBA128_FLOAT
format - SDL_
Matrix Coefficients - Colorspace matrix coefficients.
- SDL_
Packed Layout - Packed component layout.
- SDL_
Packed Order - Packed component order, high bit -> low bit.
- SDL_
Palette - A set of indexed colors representing a palette.
- SDL_
Pixel Format - Pixel format.
- SDL_
Pixel Format Details - Details about the format of a pixel.
- SDL_
Pixel Type - Pixel type.
- SDL_
Transfer Characteristics - Colorspace transfer characteristics.
Constants§
- SDL_
ALPHA_ OPAQUE - A fully opaque 8-bit alpha value.
- SDL_
ALPHA_ OPAQUE_ FLOAT - A fully opaque floating point alpha value.
- SDL_
ALPHA_ TRANSPARENT - A fully transparent 8-bit alpha value.
- SDL_
ALPHA_ TRANSPARENT_ FLOAT - A fully transparent floating point alpha value.
- SDL_
ARRAYORDER_ ABGR - SDL_
ARRAYORDER_ ARGB - SDL_
ARRAYORDER_ BGR - SDL_
ARRAYORDER_ BGRA - SDL_
ARRAYORDER_ NONE - SDL_
ARRAYORDER_ RGB - SDL_
ARRAYORDER_ RGBA - SDL_
BITMAPORDER_ 1234 - SDL_
BITMAPORDER_ 4321 - SDL_
BITMAPORDER_ NONE - SDL_
CHROMA_ LOCATION_ CENTER - In JPEG/JFIF, H.261, and MPEG-1, Cb and Cr are taken at the center of the 2x2 square. In other words, they are offset one-half pixel to the right and one-half pixel down compared to the top-left pixel.
- SDL_
CHROMA_ LOCATION_ LEFT - In MPEG-2, MPEG-4, and AVC, Cb and Cr are taken on midpoint of the left-edge of the 2x2 square. In other words, they have the same horizontal location as the top-left pixel, but is shifted one-half pixel down vertically.
- SDL_
CHROMA_ LOCATION_ NONE - RGB, no chroma sampling
- SDL_
CHROMA_ LOCATION_ TOPLEFT - In HEVC for BT.2020 and BT.2100 content (in particular on Blu-rays), Cb and Cr are sampled at the same location as the group’s top-left Y pixel (“co-sited”, “co-located”).
- SDL_
COLORSPACE_ BT601_ FULL - Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601
- SDL_
COLORSPACE_ BT601_ LIMITED - Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601
- SDL_
COLORSPACE_ BT709_ FULL - Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709
- SDL_
COLORSPACE_ BT709_ LIMITED - Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709
- SDL_
COLORSPACE_ BT2020_ FULL - Equivalent to DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P2020
- SDL_
COLORSPACE_ BT2020_ LIMITED - Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P2020
- SDL_
COLORSPACE_ HDR10 - Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020
- SDL_
COLORSPACE_ JPEG - Equivalent to DXGI_COLOR_SPACE_YCBCR_FULL_G22_NONE_P709_X601
- SDL_
COLORSPACE_ RGB_ DEFAULT - The default colorspace for RGB surfaces if no colorspace is specified
- SDL_
COLORSPACE_ SRGB - Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709
- SDL_
COLORSPACE_ SRGB_ LINEAR - Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G10_NONE_P709
- SDL_
COLORSPACE_ UNKNOWN - SDL_
COLORSPACE_ YUV_ DEFAULT - The default colorspace for YUV surfaces if no colorspace is specified
- SDL_
COLOR_ PRIMARIES_ BT601 - ITU-R BT.601-7 525, SMPTE 170M
- SDL_
COLOR_ PRIMARIES_ BT709 - ITU-R BT.709-6
- SDL_
COLOR_ PRIMARIES_ BT470BG - ITU-R BT.470-6 System B, G / ITU-R BT.601-7 625
- SDL_
COLOR_ PRIMARIES_ BT470M - ITU-R BT.470-6 System M
- SDL_
COLOR_ PRIMARIES_ BT2020 - ITU-R BT.2020-2 / ITU-R BT.2100-0
- SDL_
COLOR_ PRIMARIES_ CUSTOM - SDL_
COLOR_ PRIMARIES_ EBU3213 - EBU Tech. 3213-E
- SDL_
COLOR_ PRIMARIES_ GENERIC_ FILM - Generic film (color filters using Illuminant C)
- SDL_
COLOR_ PRIMARIES_ SMPT E240 - SMPTE 240M, functionally the same as
SDL_COLOR_PRIMARIES_BT601
- SDL_
COLOR_ PRIMARIES_ SMPT E431 - SMPTE RP 431-2
- SDL_
COLOR_ PRIMARIES_ SMPT E432 - SMPTE EG 432-1 / DCI P3
- SDL_
COLOR_ PRIMARIES_ UNKNOWN - SDL_
COLOR_ PRIMARIES_ UNSPECIFIED - SDL_
COLOR_ PRIMARIES_ XYZ - SMPTE ST 428-1
- SDL_
COLOR_ RANGE_ FULL - Full range, e.g. 0-255 for 8-bit RGB and luma, and 1-255 for 8-bit chroma
- SDL_
COLOR_ RANGE_ LIMITED - Narrow range, e.g. 16-235 for 8-bit RGB and luma, and 16-240 for 8-bit chroma
- SDL_
COLOR_ RANGE_ UNKNOWN - SDL_
COLOR_ TYPE_ RGB - SDL_
COLOR_ TYPE_ UNKNOWN - SDL_
COLOR_ TYPE_ YCBCR - SDL_
MATRIX_ COEFFICIENTS_ BT601 - ITU-R BT.601-7 525
- SDL_
MATRIX_ COEFFICIENTS_ BT709 - ITU-R BT.709-6
- SDL_
MATRIX_ COEFFICIENTS_ BT470BG - ITU-R BT.470-6 System B, G / ITU-R BT.601-7 625, functionally the same as
SDL_MATRIX_COEFFICIENTS_BT601
- SDL_
MATRIX_ COEFFICIENTS_ BT2020_ CL - ITU-R BT.2020-2 constant luminance
- SDL_
MATRIX_ COEFFICIENTS_ BT2020_ NCL - ITU-R BT.2020-2 non-constant luminance
- SDL_
MATRIX_ COEFFICIENTS_ CHROMA_ DERIVED_ CL - SDL_
MATRIX_ COEFFICIENTS_ CHROMA_ DERIVED_ NCL - SDL_
MATRIX_ COEFFICIENTS_ CUSTOM - SDL_
MATRIX_ COEFFICIENTS_ FCC - US FCC Title 47
- SDL_
MATRIX_ COEFFICIENTS_ ICTCP - ITU-R BT.2100-0 ICTCP
- SDL_
MATRIX_ COEFFICIENTS_ IDENTITY - SDL_
MATRIX_ COEFFICIENTS_ SMPT E240 - SMPTE 240M
- SDL_
MATRIX_ COEFFICIENTS_ SMPT E2085 - SMPTE ST 2085
- SDL_
MATRIX_ COEFFICIENTS_ UNSPECIFIED - SDL_
MATRIX_ COEFFICIENTS_ YCGCO - SDL_
PACKEDLAYOUT_ 332 - SDL_
PACKEDLAYOUT_ 565 - SDL_
PACKEDLAYOUT_ 1555 - SDL_
PACKEDLAYOUT_ 4444 - SDL_
PACKEDLAYOUT_ 5551 - SDL_
PACKEDLAYOUT_ 8888 - SDL_
PACKEDLAYOUT_ 1010102 - SDL_
PACKEDLAYOUT_ 2101010 - SDL_
PACKEDLAYOUT_ NONE - SDL_
PACKEDORDER_ ABGR - SDL_
PACKEDORDER_ ARGB - SDL_
PACKEDORDER_ BGRA - SDL_
PACKEDORDER_ BGRX - SDL_
PACKEDORDER_ NONE - SDL_
PACKEDORDER_ RGBA - SDL_
PACKEDORDER_ RGBX - SDL_
PACKEDORDER_ XBGR - SDL_
PACKEDORDER_ XRGB - SDL_
PIXELFORMAT_ ABGR32 - SDL_
PIXELFORMAT_ ABGR64 - SDL_
PIXELFORMAT_ ABGR64_ FLOAT - SDL_
PIXELFORMAT_ ABGR128_ FLOAT - SDL_
PIXELFORMAT_ ABGR1555 - SDL_
PIXELFORMAT_ ABGR4444 - SDL_
PIXELFORMAT_ ABGR8888 - SDL_
PIXELFORMAT_ ABGR2101010 - SDL_
PIXELFORMAT_ ARGB32 - SDL_
PIXELFORMAT_ ARGB64 - SDL_
PIXELFORMAT_ ARGB64_ FLOAT - SDL_
PIXELFORMAT_ ARGB128_ FLOAT - SDL_
PIXELFORMAT_ ARGB1555 - SDL_
PIXELFORMAT_ ARGB4444 - SDL_
PIXELFORMAT_ ARGB8888 - SDL_
PIXELFORMAT_ ARGB2101010 - SDL_
PIXELFORMAT_ BGR24 - SDL_
PIXELFORMAT_ BGR48 - SDL_
PIXELFORMAT_ BGR48_ FLOAT - SDL_
PIXELFORMAT_ BGR96_ FLOAT - SDL_
PIXELFORMAT_ BGR565 - SDL_
PIXELFORMAT_ BGRA32 - SDL_
PIXELFORMAT_ BGRA64 - SDL_
PIXELFORMAT_ BGRA64_ FLOAT - SDL_
PIXELFORMAT_ BGRA128_ FLOAT - SDL_
PIXELFORMAT_ BGRA4444 - SDL_
PIXELFORMAT_ BGRA5551 - SDL_
PIXELFORMAT_ BGRA8888 - SDL_
PIXELFORMAT_ BGRX32 - SDL_
PIXELFORMAT_ BGRX8888 - SDL_
PIXELFORMAT_ EXTERNAL_ OES - Android video texture format
- SDL_
PIXELFORMAT_ INDE X8 - SDL_
PIXELFORMAT_ INDE X1LSB - SDL_
PIXELFORMAT_ INDE X1MSB - SDL_
PIXELFORMAT_ INDE X2LSB - SDL_
PIXELFORMAT_ INDE X2MSB - SDL_
PIXELFORMAT_ INDE X4LSB - SDL_
PIXELFORMAT_ INDE X4MSB - SDL_
PIXELFORMAT_ IYUV - Planar mode: Y + U + V (3 planes)
- SDL_
PIXELFORMAT_ NV12 - Planar mode: Y + U/V interleaved (2 planes)
- SDL_
PIXELFORMAT_ NV21 - Planar mode: Y + V/U interleaved (2 planes)
- SDL_
PIXELFORMAT_ P010 - Planar mode: Y + U/V interleaved (2 planes)
- SDL_
PIXELFORMAT_ RGB24 - SDL_
PIXELFORMAT_ RGB48 - SDL_
PIXELFORMAT_ RGB48_ FLOAT - SDL_
PIXELFORMAT_ RGB96_ FLOAT - SDL_
PIXELFORMAT_ RGB332 - SDL_
PIXELFORMAT_ RGB565 - SDL_
PIXELFORMAT_ RGBA32 - SDL_
PIXELFORMAT_ RGBA64 - SDL_
PIXELFORMAT_ RGBA64_ FLOAT - SDL_
PIXELFORMAT_ RGBA128_ FLOAT - SDL_
PIXELFORMAT_ RGBA4444 - SDL_
PIXELFORMAT_ RGBA5551 - SDL_
PIXELFORMAT_ RGBA8888 - SDL_
PIXELFORMAT_ RGBX32 - SDL_
PIXELFORMAT_ RGBX8888 - SDL_
PIXELFORMAT_ UNKNOWN - SDL_
PIXELFORMAT_ UYVY - Packed mode: U0+Y0+V0+Y1 (1 plane)
- SDL_
PIXELFORMAT_ XBGR32 - SDL_
PIXELFORMAT_ XBGR1555 - SDL_
PIXELFORMAT_ XBGR4444 - SDL_
PIXELFORMAT_ XBGR8888 - SDL_
PIXELFORMAT_ XBGR2101010 - SDL_
PIXELFORMAT_ XRGB32 - SDL_
PIXELFORMAT_ XRGB1555 - SDL_
PIXELFORMAT_ XRGB4444 - SDL_
PIXELFORMAT_ XRGB8888 - SDL_
PIXELFORMAT_ XRGB2101010 - SDL_
PIXELFORMAT_ YUY2 - Packed mode: Y0+U0+Y1+V0 (1 plane)
- SDL_
PIXELFORMAT_ YV12 - Planar mode: Y + V + U (3 planes)
- SDL_
PIXELFORMAT_ YVYU - Packed mode: Y0+V0+Y1+U0 (1 plane)
- SDL_
PIXELTYPE_ ARRAY F16 - SDL_
PIXELTYPE_ ARRAY F32 - SDL_
PIXELTYPE_ ARRAY U8 - SDL_
PIXELTYPE_ ARRAY U16 - SDL_
PIXELTYPE_ ARRAY U32 - SDL_
PIXELTYPE_ INDE X1 - SDL_
PIXELTYPE_ INDE X2 - SDL_
PIXELTYPE_ INDE X4 - SDL_
PIXELTYPE_ INDE X8 - SDL_
PIXELTYPE_ PACKE D8 - SDL_
PIXELTYPE_ PACKE D16 - SDL_
PIXELTYPE_ PACKE D32 - SDL_
PIXELTYPE_ UNKNOWN - SDL_
TRANSFER_ CHARACTERISTICS_ BT601 - SMPTE ST 170M / ITU-R BT.601-7 525 or 625
- SDL_
TRANSFER_ CHARACTERISTICS_ BT709 - Rec. ITU-R BT.709-6 / ITU-R BT1361
- SDL_
TRANSFER_ CHARACTERISTICS_ BT1361 - ITU-R BT1361 Extended Colour Gamut
- SDL_
TRANSFER_ CHARACTERISTICS_ BT2020_ 10BIT - ITU-R BT2020 for 10-bit system
- SDL_
TRANSFER_ CHARACTERISTICS_ BT2020_ 12BIT - ITU-R BT2020 for 12-bit system
- SDL_
TRANSFER_ CHARACTERISTICS_ CUSTOM - SDL_
TRANSFER_ CHARACTERISTICS_ GAMM A22 - ITU-R BT.470-6 System M / ITU-R BT1700 625 PAL & SECAM
- SDL_
TRANSFER_ CHARACTERISTICS_ GAMM A28 - ITU-R BT.470-6 System B, G
- SDL_
TRANSFER_ CHARACTERISTICS_ HLG - ARIB STD-B67, known as “hybrid log-gamma” (HLG)
- SDL_
TRANSFER_ CHARACTERISTICS_ IEC61966 - IEC 61966-2-4
- SDL_
TRANSFER_ CHARACTERISTICS_ LINEAR - SDL_
TRANSFER_ CHARACTERISTICS_ LOG100 - SDL_
TRANSFER_ CHARACTERISTICS_ LOG100_ SQRT10 - SDL_
TRANSFER_ CHARACTERISTICS_ PQ - SMPTE ST 2084 for 10-, 12-, 14- and 16-bit systems
- SDL_
TRANSFER_ CHARACTERISTICS_ SMPT E240 - SMPTE ST 240M
- SDL_
TRANSFER_ CHARACTERISTICS_ SMPT E428 - SMPTE ST 428-1
- SDL_
TRANSFER_ CHARACTERISTICS_ SRGB - IEC 61966-2-1 (sRGB or sYCC)
- SDL_
TRANSFER_ CHARACTERISTICS_ UNKNOWN - SDL_
TRANSFER_ CHARACTERISTICS_ UNSPECIFIED
Functions§
- SDL_
BITSPERPIXEL - A macro to determine an SDL_PixelFormat’s bits per pixel.
- SDL_
BYTESPERPIXEL - A macro to determine an SDL_PixelFormat’s bytes per pixel.
- SDL_
COLORSPACECHROMA - A macro to retrieve the chroma sample location of an
SDL_Colorspace
. - SDL_
COLORSPACEMATRIX - A macro to retrieve the matrix coefficients of an
SDL_Colorspace
. - SDL_
COLORSPACEPRIMARIES - A macro to retrieve the primaries of an
SDL_Colorspace
. - SDL_
COLORSPACERANGE - A macro to retrieve the range of an
SDL_Colorspace
. - SDL_
COLORSPACETRANSFER - A macro to retrieve the transfer characteristics of an
SDL_Colorspace
. - SDL_
COLORSPACETYPE - A macro to retrieve the type of an
SDL_Colorspace
. - SDL_
Create ⚠Palette - Create a palette structure with the specified number of color entries.
- SDL_
DEFINE_ COLORSPACE - A macro for defining custom
SDL_Colorspace
formats. - SDL_
DEFINE_ PIXELFORMAT - A macro for defining custom non-FourCC pixel formats.
- SDL_
DEFINE_ PIXELFOURCC - A macro for defining custom FourCC pixel formats.
- SDL_
Destroy ⚠Palette - Free a palette created with
SDL_CreatePalette()
. - SDL_
GetMasks ⚠ForPixel Format - Convert one of the enumerated pixel formats to a bpp value and RGBA masks.
- SDL_
GetPixel ⚠Format Details - Create an
SDL_PixelFormatDetails
structure corresponding to a pixel format. - SDL_
GetPixel ⚠Format ForMasks - Convert a bpp value and RGBA masks to an enumerated pixel format.
- SDL_
GetPixel ⚠Format Name - Get the human readable name of a pixel format.
- SDL_
GetRGB ⚠ - Get RGB values from a pixel in the specified format.
- SDL_
GetRGBA ⚠ - Get RGBA values from a pixel in the specified format.
- SDL_
ISCOLORSPACE_ FULL_ RANGE - A macro to determine if an
SDL_Colorspace
has a full range. - SDL_
ISCOLORSPACE_ LIMITED_ RANGE - A macro to determine if an
SDL_Colorspace
has a limited range. - SDL_
ISCOLORSPACE_ MATRIX_ BT601 - A macro to determine if an
SDL_Colorspace
uses BT601 (or BT470BG) matrix coefficients. - SDL_
ISCOLORSPACE_ MATRIX_ BT709 - A macro to determine if an
SDL_Colorspace
uses BT709 matrix coefficients. - SDL_
ISCOLORSPACE_ MATRIX_ BT2020_ NCL - A macro to determine if an
SDL_Colorspace
uses BT2020_NCL matrix coefficients. - SDL_
ISPIXELFORMAT_ 10BIT - A macro to determine if an
SDL_PixelFormat
is a 10-bit format. - SDL_
ISPIXELFORMAT_ ALPHA - A macro to determine if an
SDL_PixelFormat
has an alpha channel. - SDL_
ISPIXELFORMAT_ ARRAY - A macro to determine if an
SDL_PixelFormat
is an array format. - SDL_
ISPIXELFORMAT_ FLOAT - A macro to determine if an
SDL_PixelFormat
is a floating point format. - SDL_
ISPIXELFORMAT_ FOURCC - A macro to determine if an
SDL_PixelFormat
is a “FourCC” format. - SDL_
ISPIXELFORMAT_ INDEXED - A macro to determine if an
SDL_PixelFormat
is an indexed format. - SDL_
ISPIXELFORMAT_ PACKED - A macro to determine if an
SDL_PixelFormat
is a packed format. - SDL_
MapRGB ⚠ - Map an RGB triple to an opaque pixel value for a given pixel format.
- SDL_
MapRGBA ⚠ - Map an RGBA quadruple to a pixel value for a given pixel format.
- SDL_
PIXELFLAG - A macro to retrieve the flags of an
SDL_PixelFormat
. - SDL_
PIXELLAYOUT - A macro to retrieve the layout of an
SDL_PixelFormat
. - SDL_
PIXELORDER - A macro to retrieve the order of an
SDL_PixelFormat
. - SDL_
PIXELTYPE - A macro to retrieve the type of an
SDL_PixelFormat
. - SDL_
SetPalette ⚠Colors - Set a range of colors in a palette.