imgLoadAnimationTypedIo function image

Pointer<ImgAnimation> imgLoadAnimationTypedIo(
  1. Pointer<SdlIoStream> src,
  2. bool closeio,
  3. String? type
)

Load an animation from an SDL datasource

Even though this function accepts a file type, SDL_image may still try other decoders that are capable of detecting file type from the contents of the image data, but may rely on the caller-provided type string for formats that it cannot autodetect. If type is NULL, SDL_image will rely solely on its ability to guess the format.

If closeio is true, src will be closed before returning, whether this function succeeds or not. SDL_image reads everything it needs from src during this call in any case.

When done with the returned animation, the app should dispose of it with a call to IMG_FreeAnimation().

\param src an SDL_IOStream that data will be read from. \param closeio true to close/free the SDL_IOStream before returning, false to leave it open. \param type a filename extension that represent this data ("GIF", etc). \returns a new IMG_Animation, or NULL on error.

\since This function is available since SDL_image 3.0.0.

\sa IMG_LoadAnimation \sa IMG_LoadAnimation_IO \sa IMG_LoadAPNGAnimation_IO \sa IMG_LoadAVIFAnimation_IO \sa IMG_LoadGIFAnimation_IO \sa IMG_LoadWEBPAnimation_IO \sa IMG_FreeAnimation

extern SDL_DECLSPEC IMG_Animation * SDLCALL IMG_LoadAnimationTyped_IO(SDL_IOStream *src, bool closeio, const char *type)

Implementation

Pointer<ImgAnimation> imgLoadAnimationTypedIo(
  Pointer<SdlIoStream> src,
  bool closeio,
  String? type,
) {
  final imgLoadAnimationTypedIoLookupFunction = _libImage
      .lookupFunction<
        Pointer<ImgAnimation> Function(
          Pointer<SdlIoStream> src,
          Uint8 closeio,
          Pointer<Utf8> type,
        ),
        Pointer<ImgAnimation> Function(
          Pointer<SdlIoStream> src,
          int closeio,
          Pointer<Utf8> type,
        )
      >('IMG_LoadAnimationTyped_IO');
  final typePointer = type != null ? type.toNativeUtf8() : nullptr;
  final result = imgLoadAnimationTypedIoLookupFunction(
    src,
    closeio ? 1 : 0,
    typePointer,
  );
  calloc.free(typePointer);
  return result;
}