sdlxGetSurfaceColorMod function surface

bool sdlxGetSurfaceColorMod(
  1. Pointer<SdlSurface> surface,
  2. SdlxColor color
)

Get the additional color value multiplied into blit operations.

\param surface the SDL_Surface structure to query. \param r a pointer filled in with the current red color value. \param g a pointer filled in with the current green color value. \param b a pointer filled in with the current blue color value. \returns true on success or false on failure; call SDL_GetError() for more information.

\threadsafety This function can be called on different threads with different surfaces.

\since This function is available since SDL 3.2.0.

\sa SDL_GetSurfaceAlphaMod \sa SDL_SetSurfaceColorMod

extern SDL_DECLSPEC bool SDLCALL SDL_GetSurfaceColorMod(SDL_Surface *surface, Uint8 *r, Uint8 *g, Uint8 *b)

Implementation

bool sdlxGetSurfaceColorMod(Pointer<SdlSurface> surface, SdlxColor color) {
  final rPointer = ffi.calloc<Uint8>();
  final gPointer = ffi.calloc<Uint8>();
  final bPointer = ffi.calloc<Uint8>();
  final aPointer = ffi.calloc<Uint8>();
  var result = sdlGetSurfaceColorMod(surface, rPointer, gPointer, bPointer);
  if (result) {
    color
      ..r = rPointer.value
      ..g = gPointer.value
      ..b = bPointer.value;
    result = sdlGetSurfaceAlphaMod(surface, aPointer);
    if (result) {
      color.a = aPointer.value;
    }
  }
  rPointer.callocFree();
  gPointer.callocFree();
  bPointer.callocFree();
  aPointer.callocFree();
  return result;
}