Skip to content
modkitv0.2

gif.h

#include <modkit/gif.h>14 functions · 2 structs · 1 enums · 4 typedefs · 2 macros

Optional animated GIF decoding and playback.

Animated GIF support is enabled with MODKIT_ENABLE_GIF. Disabled builds provide the same API as unsupported stubs. A GIF keeps its composited RGBA frames in CPU memory and updates one stable RGBA8 texture as it plays.

Functions

mk_gif_desc_initfunction

mk_gif_desc mk_gif_desc_init(void)

Return the default GIF load descriptor.

Returns The resulting value.

mk_gif_destroyfunction

void mk_gif_destroy(mk_gif_t gif)

Destroy the gif.

ParameterTypeDescription
gifmk_gif_tValue for gif.

mk_gif_get_infofunction

bool mk_gif_get_info(mk_gif_t gif, mk_gif_info *info)

Query playback and decoded-output information.

ParameterTypeDescription
gifmk_gif_tValue for gif.
infomk_gif_info *Value for info.

Returns True when the operation succeeds.

mk_gif_is_validfunction

bool mk_gif_is_valid(mk_gif_t gif)

Test whether the gif is valid.

ParameterTypeDescription
gifmk_gif_tValue for gif.

Returns True when the condition holds.

mk_gif_loadfunction

mk_gif_t mk_gif_load(const char *path, const mk_gif_desc *desc)

Load and decode a GIF from a filesystem path.

ParameterTypeDescription
pathconst char *Value for path.
descconst mk_gif_desc *Configuration descriptor.

Returns The resulting handle or value.

mk_gif_load_memfunction

mk_gif_t mk_gif_load_mem(const void *data, size_t size, const mk_gif_desc *desc)

Load and decode a GIF from encoded memory.

ParameterTypeDescription
dataconst void *Data buffer.
sizesize_tSize in bytes.
descconst mk_gif_desc *Configuration descriptor.

Returns The resulting handle or value.

mk_gif_pausefunction

bool mk_gif_pause(mk_gif_t gif)

Pause the gif.

ParameterTypeDescription
gifmk_gif_tValue for gif.

Returns True when the operation succeeds.

mk_gif_playfunction

bool mk_gif_play(mk_gif_t gif)

Play gif.

ParameterTypeDescription
gifmk_gif_tValue for gif.

Returns True when the operation succeeds.

mk_gif_restartfunction

bool mk_gif_restart(mk_gif_t gif)

Perform the gif restart operation.

ParameterTypeDescription
gifmk_gif_tValue for gif.

Returns True when the operation succeeds.

mk_gif_seek_framefunction

bool mk_gif_seek_frame(mk_gif_t gif, uint32_t frame_index)

Seek frame for the gif.

ParameterTypeDescription
gifmk_gif_tValue for gif.
frame_indexuint32_tValue for frame index.

Returns True when the operation succeeds.

mk_gif_set_loop_modefunction

bool mk_gif_set_loop_mode(mk_gif_t gif, mk_gif_loop_mode_t mode)

Set loop mode on the gif.

ParameterTypeDescription
gifmk_gif_tValue for gif.
modemk_gif_loop_mode_tValue for mode.

Returns True when the operation succeeds.

mk_gif_set_speedfunction

bool mk_gif_set_speed(mk_gif_t gif, float speed)

Set speed on the gif.

ParameterTypeDescription
gifmk_gif_tValue for gif.
speedfloatValue for speed.

Returns True when the operation succeeds.

mk_gif_texturefunction

mk_texture_t mk_gif_texture(mk_gif_t gif)

Return the stable mutable texture used by this GIF.

ParameterTypeDescription
gifmk_gif_tValue for gif.

Returns The resulting handle or value.

mk_gif_updatefunction

bool mk_gif_update(mk_gif_t gif, float delta_seconds)

Advance playback by elapsed seconds.

Arbitrary positive deltas are supported; at most one texture upload is issued for the resolved frame.

ParameterTypeDescription
gifmk_gif_tValue for gif.
delta_secondsfloatValue for delta seconds.

Returns True when the operation succeeds.

Structs

mk_gif_descstruct

Data for gif desc.

FieldTypeDescription
max_decoded_bytesuint64_tConservative limit for the final contiguous composited RGBA frame output.

mk_gif_infostruct

Data for gif info.

FieldTypeDescription
logical_widthuint16_tThe logical width.
logical_heightuint16_tThe logical height.
frame_countuint32_tThe frame count.
current_frameuint32_tThe current frame.
effective_duration_secondsdoubleThe effective duration seconds.
decoded_output_bytesuint64_tThe decoded output bytes.
source_repeat_countint32_tSource repeat metadata: -1 means no loop extension, 0 means infinite, and a positive value is the number of repeats after the first play.
speedfloatThe speed.
loop_modemk_gif_loop_mode_tThe loop mode.
playingboolThe playing.

Enums

mk_gif_loop_modeenum

Values for gif loop mode.

ValueDescription
MK_GIF_LOOP_SOURCESelects source.
MK_GIF_LOOP_ONCESelects once.
MK_GIF_LOOP_FOREVERSelects forever.

Typedefs

mk_gif_desctypedef

typedef struct mk_gif_desc mk_gif_desc

Data for gif desc.

mk_gif_infotypedef

typedef struct mk_gif_info mk_gif_info

Data for gif info.

mk_gif_loop_mode_ttypedef

typedef enum mk_gif_loop_mode mk_gif_loop_mode_t

Values for gif loop mode.

mk_gif_ttypedef

typedef struct mk_gif* mk_gif_t

Type used for gif.

Macros

MK_GIF_DEFAULT_MAX_DECODED_BYTESdefine

MK_GIF_DEFAULT_MAX_DECODED_BYTES

Maximum supported gif default decoded bytes.

MK_GIF_INVALIDdefine

MK_GIF_INVALID

Invalid sentinel for gif.