imgCreateAnimationDecoderIo function image

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

Create a decoder to read a series of images from an IOStream.

If closeio is true, src will be closed before returning if this function fails, or when the animation decoder is closed if this function succeeds.

\param src an SDL_IOStream containing a series of images. \param closeio true to close the SDL_IOStream when done, false to leave it open. \param type a filename extension that represent this data ("WEBP", etc). \returns a new IMG_AnimationDecoder, or NULL on failure; call SDL_GetError() for more information.

\since This function is available since SDL_image 3.4.0.

\sa IMG_CreateAnimationDecoder \sa IMG_CreateAnimationDecoderWithProperties \sa IMG_GetAnimationDecoderFrame \sa IMG_ResetAnimationDecoder \sa IMG_CloseAnimationDecoder

extern SDL_DECLSPEC IMG_AnimationDecoder * SDLCALL IMG_CreateAnimationDecoder_IO(SDL_IOStream *src, bool closeio, const char *type)

Implementation

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