Xo is experimental. The source is now public on GitHub, or try Xo in your browser.
Menu · gif

Docs

std/gif

On this page

Index

Types

GifErr

struct GifErr {
  msg: Str
}

Go’s error texts: gif: not enough image data, gif: too much image data, gif: invalid pixel value, gif: reading frames: unexpected EOF, gif: can't recognize format "GIF90a", gif: image is too large to encode, image too large (more than max_pixels) and the rest of image/gif’s.

Source: std/gif.xo:14

GifErr.display

fn (e: GifErr) display() -> Str

Source: std/gif.xo:18

Config

struct Config {
  width: Int
  height: Int
  palette: List[Int]
}

What DecodeConfig returns: the logical screen and the global color table (empty when there is none).

Source: std/gif.xo:22

Gif

struct Gif {
  frames: List[image.Image]
  delay: List[Int]
  disposal: List[Int]
  loop_count: Int
  width: Int
  height: Int
  palette: List[Int]
  background_index: Int
}

Go’s gif.GIF: the frames in order (each a Paletted Image whose min_x and min_y are the frame’s offset on the screen), the delays in 100ths of a second, the disposal methods (0 to 3; empty means none: Go’s nil), the loop count (-1: no loop extension, 0: forever, n: n times after the first run), the screen size and global palette (empty: none) and the background color index.

Source: std/gif.xo:34

Functions

decode

fn decode(data: Bytes, max_pixels: Int = 100000000) -> image.Image ! GifErr

Go’s gif.Decode: the first frame. A screen or frame of more than max_pixels pixels is refused before anything is allocated.

Source: std/gif.xo:47

decode_all

fn decode_all(data: Bytes, max_pixels: Int = 100000000) -> Gif ! GifErr

Go’s gif.DecodeAll.

Source: std/gif.xo:49

decode_config

fn decode_config(data: Bytes) -> Config ! GifErr

Go’s gif.DecodeConfig.

Source: std/gif.xo:51

encode

fn encode(im: image.Image, num_colors: Int = 256) -> Bytes ! GifErr

Go’s gif.Encode with Options{NumColors: num_colors} (1 to 256, else 256) and its default Floyd-Steinberg drawer: a Paletted image with at most num_colors entries is written as it is, any other image is drawn onto the first num_colors entries of the Plan 9 palette.

Source: std/gif.xo:57

encode_all

fn encode_all(g: Gif) -> Bytes ! GifErr

Go’s gif.EncodeAll.

Source: std/gif.xo:59

↑ index