sdlGetRgba function pixels

void sdlGetRgba(
  1. int pixelvalue,
  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 pixelvalue 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.2.0.

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

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

Implementation

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