pixels topic
CategoryPixels
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.
Classes
- SdlColor pixels
- SdlFColor pixels
- SdlkAlpha pixels
- SdlkArrayorder pixels
- SdlkBitmaporder pixels
- SdlkChromaLocation pixels
- SdlkColorPrimaries pixels
- SdlkColorRange pixels
- SdlkColorspace pixels
- SdlkColorType pixels
- SdlkMatrixCoefficients pixels
- SdlkPackedlayout pixels
- SdlkPackedorder pixels
- SdlkPixelformat pixels
- SdlkPixeltype pixels
- SdlkTransferCharacteristics pixels
- SdlPalette pixels
- SdlPixelFormatDetails pixels
Functions
-
sdlCreatePalette(
int ncolors) → Pointer< pixelsSdlPalette> - Create a palette structure with the specified number of color entries.
-
sdlDestroyPalette(
Pointer< pixelsSdlPalette> palette) → void - Free a palette created with SDL_CreatePalette().
-
sdlGetMasksForPixelFormat(
int format, Pointer< pixelsInt32> bpp, Pointer<Uint32> rmask, Pointer<Uint32> gmask, Pointer<Uint32> bmask, Pointer<Uint32> amask) → bool - Convert one of the enumerated pixel formats to a bpp value and RGBA masks.
-
sdlGetPixelFormatDetails(
int format) → Pointer< pixelsSdlPixelFormatDetails> - Create an SDL_PixelFormatDetails structure corresponding to a pixel format.
-
sdlGetPixelFormatForMasks(
int bpp, int rmask, int gmask, int bmask, int amask) → int pixels - Convert a bpp value and RGBA masks to an enumerated pixel format.
-
sdlGetPixelFormatName(
int format) → String? pixels - Get the human readable name of a pixel format.
-
sdlGetRgb(
int pixelvalue, Pointer< pixelsSdlPixelFormatDetails> format, Pointer<SdlPalette> palette, Pointer<Uint8> r, Pointer<Uint8> g, Pointer<Uint8> b) → void - Get RGB values from a pixel in the specified format.
-
sdlGetRgba(
int pixelvalue, Pointer< pixelsSdlPixelFormatDetails> format, Pointer<SdlPalette> palette, Pointer<Uint8> r, Pointer<Uint8> g, Pointer<Uint8> b, Pointer<Uint8> a) → void - Get RGBA values from a pixel in the specified format.
-
sdlMapRgb(
Pointer< pixelsSdlPixelFormatDetails> format, Pointer<SdlPalette> palette, int r, int g, int b) → int - Map an RGB triple to an opaque pixel value for a given pixel format.
-
sdlMapRgba(
Pointer< pixelsSdlPixelFormatDetails> format, Pointer<SdlPalette> palette, int r, int g, int b, int a) → int - Map an RGBA quadruple to a pixel value for a given pixel format.
-
sdlSetPaletteColors(
Pointer< pixelsSdlPalette> palette, Pointer<SdlColor> colors, int firstcolor, int ncolors) → bool - Set a range of colors in a palette.