sdlGetRgb function

void sdlGetRgb(
  1. int pixel,
  2. Pointer<SdlPixelFormat> format,
  3. Pointer<Uint8> r,
  4. Pointer<Uint8> g,
  5. Pointer<Uint8> b,
)

Get RGB values from a pixel in the specified format.

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).

\param pixel a pixel value \param format an SDL_PixelFormat structure describing the format of the pixel \param r a pointer filled in with the red component \param g a pointer filled in with the green component \param b a pointer filled in with the blue component

\since This function is available since SDL 2.0.0.

\sa SDL_GetRGBA \sa SDL_MapRGB \sa SDL_MapRGBA

extern DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixel, const SDL_PixelFormat * format, Uint8 * r, Uint8 * g, Uint8 * b)

Implementation

void sdlGetRgb(int pixel, Pointer<SdlPixelFormat> format, Pointer<Uint8> r,
    Pointer<Uint8> g, Pointer<Uint8> b) {
  final sdlGetRgbLookupFunction = libSdl2.lookupFunction<
      Void Function(Uint32 pixel, Pointer<SdlPixelFormat> format,
          Pointer<Uint8> r, Pointer<Uint8> g, Pointer<Uint8> b),
      void Function(int pixel, Pointer<SdlPixelFormat> format, Pointer<Uint8> r,
          Pointer<Uint8> g, Pointer<Uint8> b)>('SDL_GetRGB');
  return sdlGetRgbLookupFunction(pixel, format, r, g, b);
}