encodeGif

fun encodeGif(bitmap: KiteBitmap, dither: Boolean = true): ByteArray

Encode bitmap as a GIF89a. Colours are quantised to the format's 256-entry limit; images that already fit encode losslessly. Alpha is reduced to GIF's single transparent index at a 50% threshold.

dither applies Floyd-Steinberg error diffusion when quantisation actually loses colours, which is what keeps a photograph from banding. It is ignored when the palette came out exact, since there is no error to spread.


fun encodeGif(animation: KiteAnimation, dither: Boolean = true): ByteArray

Encode animation as an animated GIF89a: one shared colour table, per-frame delays, and the NETSCAPE2.0 loop count. Frames must all be canvas-sized, which is exactly what decodeAnimation produces.