Skip to content

image.decoders.decoder #

decoder is the magic-byte dispatcher that routes an image buffer to the right per-format V decoder module. It keeps the viewer format-agnostic: the viewer just calls decoder.decode(data) and gets a common.Image back.

fn decode #

fn decode(data []u8) !common.Image

decode sniffs the buffer and dispatches to the matching decoder.

fn decode_animation #

fn decode_animation(data []u8) !common.Animation

decode_animation sniffs the buffer and dispatches to a format decoder that can produce a multi-frame animation. The viewer uses this for animated GIFs; other formats fall back to the static decode() path.

fn decode_file #

fn decode_file(path string) !common.Image

decode_file reads a file from disk and decodes it.

fn sniff #

fn sniff(data []u8) string

sniff returns a short format tag based on the file's magic bytes, or an empty string when the format is not recognised.

The checks are ordered so that the most specific signatures are tested first (e.g. RIFF....WEBP needs bytes 0..3 AND 8..11).