Documentation ¶
Overview ¶
Package gif implements a GIF image decoder and encoder.
The GIF specification is at http://www.w3.org/Graphics/GIF/spec-gif89a.txt.
Index ¶
- func Decode(r io.Reader) (image.Image, error)
- func DecodeAll(r io.Reader) (*gif.GIF, error)
- func DecodeConfig(r io.Reader) (image.Config, error)
- func Encode(w io.Writer, m image.Image, o *Options) error
- func EncodeAll(w io.Writer, g *gif.GIF) error
- func EncodeStream(w io.Writer, g *StreamedGIF) error
- func ToPaletted(m image.Image, o *Options) (*image.Paletted, error)
- type GifFrame
- type MedianCutQuantizer
- type Options
- type Quantizer
- type StreamedGIF
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Decode ¶
Decode reads a GIF image from r and returns the first embedded image as an image.Image.
func DecodeAll ¶
DecodeAll reads a GIF image from r and returns the sequential frames and timing information.
func DecodeConfig ¶
DecodeConfig returns the global color model and dimensions of a GIF image without decoding the entire image.
func EncodeAll ¶
EncodeAll writes the images in g to w in GIF format with the given loop count and delay between frames.
func EncodeStream ¶
func EncodeStream(w io.Writer, g *StreamedGIF) error
EncodeAll writes the images in g to w in GIF format with the given loop count and delay between frames.
Types ¶
type MedianCutQuantizer ¶
type MedianCutQuantizer struct {
NumColor int
}
MedianCutQuantizer constructs a palette with a maximum of NumColor colors by iteratively splitting clusters of color points mapped on a three-dimensional (RGB) Euclidian space. Once the number of clusters is within the specified bounds, the resulting color is computed by averaging those within each grouping.
type Quantizer ¶
type Quantizer interface { // Quantize sets dst.Palette as well as dst's pixels. Quantize(dst *image.Paletted, r image.Rectangle, src image.Image, sp image.Point) }
A Quantizer interface is used by an encoder to construct an image with a restricted color palette.
type StreamedGIF ¶
type StreamedGIF struct { Frames chan GifFrame // LoopCount controls the number of times an animation will be // restarted during display. // A LoopCount of 0 means to loop forever. // A LoopCount of -1 means to show each frame only once. // Otherwise, the animation is looped LoopCount+1 times. LoopCount int // Disposal is the successive disposal methods, one per frame. For // backwards compatibility, a nil Disposal is valid to pass to EncodeAll, // and implies that each frame's disposal method is 0 (no disposal // specified). Disposal []byte // Config is the global color table (palette), width and height. A nil or // empty-color.Palette Config.ColorModel means that each frame has its own // color table and there is no global color table. Each frame's bounds must // be within the rectangle defined by the two points (0, 0) and // (Config.Width, Config.Height). // // For backwards compatibility, a zero-valued Config is valid to pass to // EncodeAll, and implies that the overall GIF's width and height equals // the first frame's bounds' Rectangle.Max point. Config image.Config // BackgroundIndex is the background index in the global color table, for // use with the DisposalBackground disposal method. BackgroundIndex byte }
GIF represents the possibly multiple images stored in a GIF file.