Module gifski::c_api

source ·
Expand description

How to use from C

gifski *g = gifski_new(&(GifskiSettings){
    .quality = 90,
});
gifski_set_file_output(g, "file.gif");

for(int i=0; i < frames; i++) {
     int res = gifski_add_frame_rgba(g, i, width, height, buffer, 5);
     if (res != GIFSKI_OK) break;
}
int res = gifski_finish(g);
if (res != GIFSKI_OK) return;

It’s safe and efficient to call gifski_add_frame_* in a loop as fast as you can get frames, because it blocks and waits until previous frames are written.

To cancel processing, make progress callback return 0 and call gifski_finish(). The write callback may still be called between the cancellation and gifski_finish() returning.

To build as a library:

cargo build --release --lib

it will create target/release/libgifski.a (static library) and target/release/libgifski.so/dylib or gifski.dll (dynamic library)

Static is recommended.

To build for iOS:

rustup target add aarch64-apple-ios
cargo build --release --lib --target aarch64-apple-ios

it will build target/aarch64-apple-ios/release/libgifski.a (ignore the warning about cdylib).

Structs§

  • Opaque handle used in methods. Note that the handle pointer is actually Arc<GifskiHandleInternal>, but Arc::into_raw is nice enough to point past the counter.
  • Settings for creating a new encoder instance. See gifski_new

Functions§