![]() |
tinyimg 1.0.0
Lightweight image manipulation library for Cloudflare Workers
|
Graphics Interchange Format codec. More...
#include "tinyimg/codec/codec.h"Go to the source code of this file.
Variables | |
| const TinyCodec | tiny_codec_gif |
| The GIF codec. | |
Graphics Interchange Format codec.
|
extern |
The GIF codec.
Decodes the first frame of either version, with a global or a local color table, interlaced or not, and honors the graphic control extension's transparent index. probe reports how many frames the file holds, so an animation is identifiable without decoding it; composing or re-timing frames is out of scope.
The canvas is the logical screen the file declares rather than the frame, which for a frame smaller than the screen or placed at an offset is what a viewer shows. A file with a transparent index decodes to four channels and one without to three.
Encoding writes a single frame with one global color table. An image already inside 256 colors keeps them exactly, so a logo or a flat illustration round trips without loss; anything wider goes through an octree quantizer with Floyd-Steinberg error diffusion, which is applied when and only when colors had to be discarded. A source with alpha spends one palette entry on a transparent index, since the format has no partial transparency to spend it on.