Overview
Package gif implements a GIF image decoder and encoder.
The GIF specification is at .
Index
- func Decode(r io.Reader) (image.Image, error)
- func Encode(w io.Writer, m image.Image, o *Options) error
- type GIF
- type Options
Disposal Methods.
func
¶
Decode reads a GIF image from r and returns the first embedded image as an
image.Image.
func DecodeConfig
DecodeConfig returns the global color model and dimensions of a GIF image
without decoding the entire image.
Encode writes the Image m to w in GIF format.
func EncodeAll
EncodeAll writes the images in g to w in GIF format with the given loop count
and delay between frames.
type GIF
- type GIF struct {
- Image []*image. // The successive images.
- LoopCount int // The loop count.
- // 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 []
- // 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.
- // 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.
func
¶
DecodeAll reads a GIF image from r and returns the sequential frames and timing
information.
- type Options struct {
- // NumColors is the maximum number of colors used in the image.
- // It ranges from 1 to 256.
- NumColors
- // Quantizer is used to produce a palette with size NumColors.
- // palette.Plan9 is used in place of a nil Quantizer.
- Quantizer draw.
- // Drawer is used to convert the source image to the desired palette.
- // draw.FloydSteinberg is used in place of a nil Drawer.
- }
Options are the encoding parameters.