sdlGetRgba function

void sdlGetRgba(
  1. int pixel,
  2. Pointer<SdlPixelFormatDetails> format,
  3. Pointer<SdlPalette> palette,
  4. Pointer<Uint8> r,
  5. Pointer<Uint8> g,
  6. Pointer<Uint8> b,
  7. 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 a pointer to SDL_PixelFormatDetails describing the pixel format. \param palette an optional palette for indexed formats, may be NULL. \param r a pointer filled in with the red component, may be NULL. \param g a pointer filled in with the green component, may be NULL. \param b a pointer filled in with the blue component, may be NULL. \param a a pointer filled in with the alpha component, may be NULL.

\threadsafety It is safe to call this function from any thread, as long as the palette is not modified.

\since This function is available since SDL 3.1.3.

\sa SDL_GetPixelFormatDetails \sa SDL_GetRGB \sa SDL_MapRGB \sa SDL_MapRGBA

extern SDL_DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel, const SDL_PixelFormatDetails *format, const SDL_Palette *palette, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a)

Implementation

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