首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

image/gif

  • import "image/gif"
  • Overview
  • Index

概观

包gif实现了一个GIF图像解码器和编码器。

The GIF specification is at http://www.w3.org/Graphics/GIF/spec-gif89a.txt.

索引

  • Constants
  • func Decode(r io.Reader) (image.Image, 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) error
  • type GIF
  • func DecodeAll(r io.Reader) (*GIF, error)
  • type Options

包文件

常量

处置方法。

代码语言:javascript
复制
const (
        DisposalNone       = 0x01
        DisposalBackground = 0x02
        DisposalPrevious   = 0x03
)

func DecodeSource

代码语言:javascript
复制
func Decode(r io.Reader) (image.Image, error)

Decode从r中读取GIF图像并将第一个嵌入图像作为图像返回。图像。

func DecodeConfigSource

代码语言:javascript
复制
func DecodeConfig(r io.Reader) (image.Config, error)

DecodeConfig返回GIF图像的全局颜色模型和尺寸,而不用解码整个图像。

func EncodeSource

代码语言:javascript
复制
func Encode(w io.Writer, m image.Image, o *Options) error

Encode将图像m以GIF格式写入w。

func EncodeAllSource

代码语言:javascript
复制
func EncodeAll(w io.Writer, g *GIF) error

EncodeAll将g中的图像以GIF格式写入w,给定的循环数和帧之间的延迟。

type GIFSource

GIF表示可能存储在GIF文件中的多个图像。

代码语言:javascript
复制
type GIF struct {
        Image     []*image.Paletted // The successive images.
        Delay     []int             // The successive delay times, one per frame, in 100ths of a second.
        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 []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
}

func DecodeAllSource

代码语言:javascript
复制
func DecodeAll(r io.Reader) (*GIF, error)

DecodeAll从r读取GIF图像并返回连续的帧和时间信息。

type OptionsSource

Options是编码参数。

代码语言:javascript
复制
type Options struct {
        // NumColors is the maximum number of colors used in the image.
        // It ranges from 1 to 256.
        NumColors int

        // Quantizer is used to produce a palette with size NumColors.
        // palette.Plan9 is used in place of a nil Quantizer.
        Quantizer draw.Quantizer

        // Drawer is used to convert the source image to the desired palette.
        // draw.FloydSteinberg is used in place of a nil Drawer.
        Drawer draw.Drawer
}

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com