# package gif
`import "image/gif"`
gif包实现了gif文件的编码器和解码器。gif格式参见:[http://www.w3.org/Graphics/GIF/spec-gif89a.txt](http://www.w3.org/Graphics/GIF/spec-gif89a.txt)
## Index
* [type Options](#Options)
* [func Decode(r io.Reader) (image.Image, error)](#Decode)
* [func DecodeConfig(r io.Reader) (image.Config, error)](#DecodeConfig)
* [func Encode(w io.Writer, m image.Image, o \*Options) error](#Encode)
* [type GIF](#GIF)
* [func DecodeAll(r io.Reader) (\*GIF, error)](#DecodeAll)
* [func EncodeAll(w io.Writer, g \*GIF) error](#EncodeAll)
## type [Options](https://github.com/golang/go/blob/master/src/image/gif/writer.go#L246 "View Source")
```
type Options struct {
// NumColors是图像中的最多颜色数,范围[1, 256]
NumColors int
// Quantizer用于生成NumColors大小的调色板,为nil时默认使用palette.Plan9
Quantizer draw.Quantizer
// Drawer用于将图像写入期望的调色板格式的图像,为nil时会使用draw.FloydSteinberg
Drawer draw.Drawer
}
```
Options是编码参数。
## func [Decode](https://github.com/golang/go/blob/master/src/image/gif/reader.go#L414 "View Source")
```
func Decode(r io.Reader) (image.Image, error)
```
从文件流解码并返回GIF文件中的第一幅图像。
## func [DecodeConfig](https://github.com/golang/go/blob/master/src/image/gif/reader.go#L446 "View Source")
```
func DecodeConfig(r io.Reader) (image.Config, error)
```
返回GIF图像的色彩模型和尺寸;函数不会解码整个图像文件。
## func [Encode](https://github.com/golang/go/blob/master/src/image/gif/writer.go#L291 "View Source")
```
func Encode(w io.Writer, m image.Image, o *Options) error
```
函数将图像以GIF格式写入w中。
## type [GIF](https://github.com/golang/go/blob/master/src/image/gif/reader.go#L423 "View Source")
```
type GIF struct {
Image []*image.Paletted // 连续的图像
Delay []int // 每一帧延迟时间,单位是0.01s
LoopCount int // 总的循环时间
}
```
GIF类型代表可能保存在GIF文件里的多幅图像。
### func [DecodeAll](https://github.com/golang/go/blob/master/src/image/gif/reader.go#L431 "View Source")
```
func DecodeAll(r io.Reader) (*GIF, error)
```
函数从r中读取一个GIF格式文件;返回值中包含了连续的图帧和时间信息。
### func [EncodeAll](https://github.com/golang/go/blob/master/src/image/gif/writer.go#L262 "View Source")
```
func EncodeAll(w io.Writer, g *GIF) error
```
函数将g中所有的图像按指定的每帧延迟和累计循环时间写入w中。
- 库
- package achive
- package tar
- package zip
- package bufio
- package builtin
- package bytes
- package compress
- package bzip2
- package flate
- package gzip
- package lzw
- package zlib
- package container
- package heap
- package list
- package ring
- package crypto
- package aes
- package cipher
- package des
- package dsa
- package ecdsa
- package elliptic
- package hmac
- package md5
- package rand
- package rc4
- package rsa
- package sha1
- package sha256
- package sha512
- package subtle
- package tls
- package x509
- package pkix
- package database
- package sql
- package driver
- package encoding
- package ascii85
- package asn1
- package base32
- package base64
- package binary
- package csv
- package gob
- package hex
- package json
- package pem
- package xml
- package errors
- package expvar
- package flag
- package fmt
- package go
- package doc
- package format
- package parser
- package printer
- package hash
- package adler32
- package crc32
- package crc64
- package fnv
- package html
- package template
- package image
- package color
- package palette
- package draw
- package gif
- package jpeg
- package png
- package index
- package suffixarray
- package io
- package ioutil
- package log
- package syslog
- package math
- package big
- package cmplx
- package rand
- package mime
- package multipart
- package net
- package http
- package cgi
- package cookiejar
- package fcgi
- package httptest
- package httputil
- package pprof
- package mail
- package rpc
- package jsonrpc
- package smtp
- package textproto
- package url
- package os
- package exec
- package signal
- package user
- package path
- package filepath
- package reflect
- package regexp
- package runtime
- package cgo
- package debug
- package pprof
- package race
- package sort
- package strconv
- package strings
- package sync
- package atomic
- package text
- package scanner
- package tabwriter
- package template
- package time
- package unicode
- package utf16
- package utf8
- package unsafe