1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
<h1> Package gif </h1> <ul id="short-nav">
<li><code>import "image/gif"</code></li>
<li><a href="#pkg-overview" class="overviewLink">Overview</a></li>
<li><a href="#pkg-index" class="indexLink">Index</a></li>
</ul> <h2 id="pkg-overview">Overview </h2> <p>Package gif implements a GIF image decoder and encoder. </p>
<p>The GIF specification is at <a href="https://www.w3.org/Graphics/GIF/spec-gif89a.txt">https://www.w3.org/Graphics/GIF/spec-gif89a.txt</a>. </p> <h2 id="pkg-index">Index </h2> <ul id="manual-nav">
<li><a href="#pkg-constants">Constants</a></li>
<li><a href="#Decode">func Decode(r io.Reader) (image.Image, error)</a></li>
<li><a href="#DecodeConfig">func DecodeConfig(r io.Reader) (image.Config, error)</a></li>
<li><a href="#Encode">func Encode(w io.Writer, m image.Image, o *Options) error</a></li>
<li><a href="#EncodeAll">func EncodeAll(w io.Writer, g *GIF) error</a></li>
<li><a href="#GIF">type GIF</a></li>
<li> <a href="#DecodeAll">func DecodeAll(r io.Reader) (*GIF, error)</a>
</li>
<li><a href="#Options">type Options</a></li>
</ul> <h3>Package files</h3> <p> <span>reader.go</span> <span>writer.go</span> </p> <h2 id="pkg-constants">Constants</h2> <p>Disposal Methods. </p>
<pre data-language="go">const (
DisposalNone = 0x01
DisposalBackground = 0x02
DisposalPrevious = 0x03
)</pre> <h2 id="Decode">func <span>Decode</span> </h2> <pre data-language="go">func Decode(r io.Reader) (image.Image, error)</pre> <p>Decode reads a GIF image from r and returns the first embedded image as an <span>image.Image</span>. </p>
<h2 id="DecodeConfig">func <span>DecodeConfig</span> </h2> <pre data-language="go">func DecodeConfig(r io.Reader) (image.Config, error)</pre> <p>DecodeConfig returns the global color model and dimensions of a GIF image without decoding the entire image. </p>
<h2 id="Encode">func <span>Encode</span> <span title="Added in Go 1.2">1.2</span> </h2> <pre data-language="go">func Encode(w io.Writer, m image.Image, o *Options) error</pre> <p>Encode writes the Image m to w in GIF format. </p>
<h2 id="EncodeAll">func <span>EncodeAll</span> <span title="Added in Go 1.2">1.2</span> </h2> <pre data-language="go">func EncodeAll(w io.Writer, g *GIF) error</pre> <p>EncodeAll writes the images in g to w in GIF format with the given loop count and delay between frames. </p>
<h2 id="GIF">type <span>GIF</span> </h2> <p>GIF represents the possibly multiple images stored in a GIF file. </p>
<pre data-language="go">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
}
</pre> <h3 id="DecodeAll">func <span>DecodeAll</span> </h3> <pre data-language="go">func DecodeAll(r io.Reader) (*GIF, error)</pre> <p>DecodeAll reads a GIF image from r and returns the sequential frames and timing information. </p>
<h2 id="Options">type <span>Options</span> <span title="Added in Go 1.2">1.2</span> </h2> <p>Options are the encoding parameters. </p>
<pre data-language="go">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
}
</pre><div class="_attribution">
<p class="_attribution-p">
© Google, Inc.<br>Licensed under the Creative Commons Attribution License 3.0.<br>
<a href="http://golang.org/pkg/image/gif/" class="_attribution-link">http://golang.org/pkg/image/gif/</a>
</p>
</div>
|