Spec-Zone.ru › Go

Пакет gif

  • import "image/gif"
  • Обзор
  • Индекс

Обзор

Пакет gif реализует декодер и кодировщик изображений GIF.

Спецификация GIF находится по адресу https://www.w3.org/Graphics/GIF/spec-gif89a.txt.

Индекс

  • Константы
  • 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
  • тип GIF
  • func DecodeAll(r io.Reader) (*GIF, error)
  • тип Options

Файлы пакета

reader.go writer.go

Константы

Методы удаления.

const (
    DisposalNone       = 0x01
    DisposalBackground = 0x02
    DisposalPrevious   = 0x03
)

func Decode

func Decode(r io.Reader) (image.Image, error)

Decode считывает изображение GIF из r и возвращает первое вставленное изображение как image.Image.

func DecodeConfig

func DecodeConfig(r io.Reader) (image.Config, error)

DecodeConfig возвращает глобальную модель цвета и размеры изображения GIF без декодирования всего изображения.

func Encode 1.2

func Encode(w io.Writer, m image.Image, o *Options) error

Encode записывает изображение m в формате GIF в w.

func EncodeAll 1.2

func EncodeAll(w io.Writer, g *GIF) error

EncodeAll записывает изображения в g в формате GIF в w с заданным количеством циклов и задержкой между кадрами.

тип GIF

GIF представляет собой, возможно, множество изображений, хранящихся в файле GIF.

type GIF struct {
    Image []*image.Paletted // The successive images.
    Delay []int             // The successive delay times, one per frame, in 100ths of a second.
    // 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 // Go 1.5
    // 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 // Go 1.5
    // BackgroundIndex is the background index in the global color table, for
    // use with the DisposalBackground disposal method.
    BackgroundIndex byte // Go 1.5
}

func DecodeAll

func DecodeAll(r io.Reader) (*GIF, error)

DecodeAll считывает изображение GIF из r и возвращает последовательные кадры и информацию о времени.

тип Options 1.2

Options — параметры кодирования.

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
}

© Google, Inc.
Licensed under the Creative Commons Attribution License 3.0.
http://golang.org/pkg/image/gif/

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API