-
Notifications
You must be signed in to change notification settings - Fork 15
General API
Daniel Löbl edited this page Feb 9, 2022
·
3 revisions
Creates new GIF output stream with the config provided (pConfig
).
1. pConfig
:CGIF_Config*
: Pointer to the configuration for the new GIF to be created; can be changed after cgif_newgif() returns - CGIF keeps an internal copy.
Returns pointer to new CGIF instance or NULL on error.
Adds new frame sequentially to the given open GIF stream.
-
pGIF
:CGIF*
: GIF handle (priorly created with cgif_newgif) -
pConfig
:CGIF_FrameConfig*
: Pointer to the configuration for the new frame to be added; can be changed after cgif_addframe() returns - CGIF keeps an internal copy.
Returns CGIF_OK on success or an error code.
Closes the given GIF stream.
If a previous call to cgif_addframe
failed, the previous error code will be returned.
-
pGIF
:CGIF*
: GIF handle (priorly created with cgif_newgif)
Returns CGIF_OK on success or an error code.
-
pGlobalPalette
:uint8_t*
: Global palette of GIF. Size MUST be a multiple of 3 (r,g,b format) if CGIF_ATTR_NO_GLOBAL_TABLE is not set. -
path
:const char*
: NUL terminated path to the new GIF to be created (mutually exclusive with pWriteFn). -
attrFlags
:uint32_t
: Fixed attributes of the GIF (see section Flags) -
genFlags
:uint32_t
: Flags that determine how the GIF is generated. -
width
:uint16_t
: Width (in pixels) of the complete graphic -
height
:uint16_t
: Height (in pixels) of the complete graphic -
numGlobalPaletteEntries
:uint16_t
: Number of palette entries provided with pGlobalPalette. MUST be >= 1 if CGIF_ATTR_NO_GLOBAL_TABLE is not set. -
numLoops
:uint16_t
: Number of repetitions to perform for an animated GIF (NETSCAPE2.0 extension). Only evaluated if CGIF_ATTR_IS_ANIMATED is set. -
pWriteFn
:cgif_write_fn*
Callback function to stream GIF (mutually exclusive with path). -
pContext
:void*
: Opaque pointer passed as the first parameter to pWriteFn.
-
pLocalPalette
:uint8_t*
: Local palette of Frame. Size MUST be a multiple of 3 (r,g,b format) if GIF_FRAME_ATTR_USE_LOCAL_TABLE set. -
pImageData
:uint8_t*
: Image data to be encoded. One byte per pixel (reference to palette). -
attrFlags
:uint32_t
: Fixed attributes of the Frame (see Flags). -
genFlags
:uint32_t
: Flags that determine how the Frame is generated. -
delay
:uint16_t
: delay before the next frame is shown (units of 0.01s). Only evaluated if GIF_ATTR_IS_ANIMATED is set. -
numLocalPaletteEntries
:uint16_t
: Number of palette entries provided with pLocalPalette. MUST be >= 1 if CGIF_FRAME_ATTR_USE_LOCAL_TABLE is set. -
transIndex
:uint8_t
: Transparency index. Only used when eitherCGIF_FRAME_ATTR_HAS_SET_TRANS
orCGIF_FRAME_ATTR_HAS_ALPHA
is set.
-
CGIF_ATTR_IS_ANIMATED
: Make an animated GIF (default is non-animated GIF). -
CGIF_ATTR_NO_GLOBAL_TABLE
: Disable global color table (global color table is default) -
CGIF_ATTR_HAS_TRANSPARENCY
: First entry in all color tables (index: 0) contains transparency (alpha channel) -
CGIF_FRAME_ATTR_USE_LOCAL_TABLE
: Use a local color table for a frame (local color table is not used by default) -
CGIF_FRAME_ATTR_HAS_ALPHA
: Frame contains transparency/alpha channel (index set viatransIndex
field) -
CGIF_FRAME_ATTR_HAS_SET_TRANS
: Transparency setting (which pixels are identical to previos frame) provided by user (transIndex
field) -
CGIF_FRAME_GEN_USE_TRANSPARENCY
: Use transparency optimization (set pixels that are identical to previous frame to transparent - might decrease size) -
CGIF_FRAME_GEN_USE_DIFF_WINDOW
: Do encoding just for the sub-window that has changed from the previous frame (decreases size)
-
CGIF_OK
: everything OK. The GIF stream is still valid. -
CGIF_EWRITE
: writing GIF data failed (via fwrite() or callback). -
CGIF_EALLOC
: allocating memory failed. -
CGIF_ECLOSE
: final call to fclose failed -
CGIF_EOPEN
: failed to open output file. -
CGIF_EINDEX
: user provided invalid index in image data. -
CGIF_ERROR
: something unspecified failed.