sdlGetRgba function

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

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

If the surface has no alpha component, the alpha will be returned as 0xff (100% opaque).

\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 \param a a pointer filled in with the alpha component

\since This function is available since SDL 2.0.0.

\sa SDL_GetRGB \sa SDL_MapRGB \sa SDL_MapRGBA

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

Implementation

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