Skip to main content

Module image_render

Module image_render 

Source
Expand description

Pure image → ASCII-art kernel. Decodes nothing and touches no terminal; callers pass an already-decoded RgbaImage. Mirrors render’s discipline: plain inputs, plain cell outputs, exhaustively unit-tested.

Structs§

Animation
Decoded animation: per-frame RGBA + the delay until the next frame, plus the loop count (None = infinite).

Enums§

AnimationDecode
Outcome of decode_animation.
AsciiStyle
Rendering aesthetic.

Constants§

BLOCK_SHADES
Block-shade ramp for --blocks under --no-color (no SGR available).
CELL_ASPECT
Terminal cells are about twice as tall as wide.
RAMP
Luminance ramp, darkest → brightest. Index by lum * (len-1) / 255.

Functions§

decode_animation
Decode an animated image. Returns Static for a single-frame / non-animated source (caller falls back to decode_image), Animated for a playable multi-frame animation, or Unsupported when the source is animated but its frames can’t be decoded (so the caller can show the first frame and hint). GIF loop count comes from the NETSCAPE extension; other formats default to infinite. GIF, 8-bit APNG, and animated WebP decode to Animated; a 16-bit APNG (which the image crate rejects) decodes to Unsupported — both covered by tests/animation_decode.rs.
decode_image
Decode the full image bytes to RGBA8. For animated GIFs this yields the first frame. Returns the decoder error string on failure.
output_rows
How many cell rows render_image produces for an image of the given pixel dimensions at cols columns. Pure; used for scroll math.
parse_gif_loop_count
Extract the loop count from a GIF’s NETSCAPE2.0 application extension. Returns Some(0) for infinite, Some(n) for a finite count, or None when the extension is absent (callers treat that as infinite). The image crate’s high-level decoder does not expose this, so we read it directly.
render_image
Render the image to a grid of styled cells cols wide. color controls whether per-cell foreground color is set (false ≈ --no-color).
sniff_image_format
Identify an image by its leading bytes. Returns a short format name (for the status line) or None if the bytes are not a supported image. Content-based only — never guesses from a file extension — so text never misfires.