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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
<h1> Package color </h1> <ul id="short-nav">
<li><code>import "image/color"</code></li>
<li><a href="#pkg-overview" class="overviewLink">Overview</a></li>
<li><a href="#pkg-index" class="indexLink">Index</a></li>
<li><a href="#pkg-subdirectories">Subdirectories</a></li>
</ul> <h2 id="pkg-overview">Overview </h2> <p>Package color implements a basic color library. </p> <h2 id="pkg-index">Index </h2> <ul id="manual-nav">
<li><a href="#pkg-variables">Variables</a></li>
<li><a href="#CMYKToRGB">func CMYKToRGB(c, m, y, k uint8) (uint8, uint8, uint8)</a></li>
<li><a href="#RGBToCMYK">func RGBToCMYK(r, g, b uint8) (uint8, uint8, uint8, uint8)</a></li>
<li><a href="#RGBToYCbCr">func RGBToYCbCr(r, g, b uint8) (uint8, uint8, uint8)</a></li>
<li><a href="#YCbCrToRGB">func YCbCrToRGB(y, cb, cr uint8) (uint8, uint8, uint8)</a></li>
<li><a href="#Alpha">type Alpha</a></li>
<li> <a href="#Alpha.RGBA">func (c Alpha) RGBA() (r, g, b, a uint32)</a>
</li>
<li><a href="#Alpha16">type Alpha16</a></li>
<li> <a href="#Alpha16.RGBA">func (c Alpha16) RGBA() (r, g, b, a uint32)</a>
</li>
<li><a href="#CMYK">type CMYK</a></li>
<li> <a href="#CMYK.RGBA">func (c CMYK) RGBA() (uint32, uint32, uint32, uint32)</a>
</li>
<li><a href="#Color">type Color</a></li>
<li><a href="#Gray">type Gray</a></li>
<li> <a href="#Gray.RGBA">func (c Gray) RGBA() (r, g, b, a uint32)</a>
</li>
<li><a href="#Gray16">type Gray16</a></li>
<li> <a href="#Gray16.RGBA">func (c Gray16) RGBA() (r, g, b, a uint32)</a>
</li>
<li><a href="#Model">type Model</a></li>
<li> <a href="#ModelFunc">func ModelFunc(f func(Color) Color) Model</a>
</li>
<li><a href="#NRGBA">type NRGBA</a></li>
<li> <a href="#NRGBA.RGBA">func (c NRGBA) RGBA() (r, g, b, a uint32)</a>
</li>
<li><a href="#NRGBA64">type NRGBA64</a></li>
<li> <a href="#NRGBA64.RGBA">func (c NRGBA64) RGBA() (r, g, b, a uint32)</a>
</li>
<li><a href="#NYCbCrA">type NYCbCrA</a></li>
<li> <a href="#NYCbCrA.RGBA">func (c NYCbCrA) RGBA() (uint32, uint32, uint32, uint32)</a>
</li>
<li><a href="#Palette">type Palette</a></li>
<li> <a href="#Palette.Convert">func (p Palette) Convert(c Color) Color</a>
</li>
<li> <a href="#Palette.Index">func (p Palette) Index(c Color) int</a>
</li>
<li><a href="#RGBA">type RGBA</a></li>
<li> <a href="#RGBA.RGBA">func (c RGBA) RGBA() (r, g, b, a uint32)</a>
</li>
<li><a href="#RGBA64">type RGBA64</a></li>
<li> <a href="#RGBA64.RGBA">func (c RGBA64) RGBA() (r, g, b, a uint32)</a>
</li>
<li><a href="#YCbCr">type YCbCr</a></li>
<li> <a href="#YCbCr.RGBA">func (c YCbCr) RGBA() (uint32, uint32, uint32, uint32)</a>
</li>
</ul> <h3>Package files</h3> <p> <span>color.go</span> <span>ycbcr.go</span> </p> <h2 id="pkg-variables">Variables</h2> <p>Standard colors. </p>
<pre data-language="go">var (
Black = Gray16{0}
White = Gray16{0xffff}
Transparent = Alpha16{0}
Opaque = Alpha16{0xffff}
)</pre> <h2 id="CMYKToRGB">func <span>CMYKToRGB</span> <span title="Added in Go 1.5">1.5</span> </h2> <pre data-language="go">func CMYKToRGB(c, m, y, k uint8) (uint8, uint8, uint8)</pre> <p>CMYKToRGB converts a <a href="#CMYK">CMYK</a> quadruple to an RGB triple. </p>
<h2 id="RGBToCMYK">func <span>RGBToCMYK</span> <span title="Added in Go 1.5">1.5</span> </h2> <pre data-language="go">func RGBToCMYK(r, g, b uint8) (uint8, uint8, uint8, uint8)</pre> <p>RGBToCMYK converts an RGB triple to a CMYK quadruple. </p>
<h2 id="RGBToYCbCr">func <span>RGBToYCbCr</span> </h2> <pre data-language="go">func RGBToYCbCr(r, g, b uint8) (uint8, uint8, uint8)</pre> <p>RGBToYCbCr converts an RGB triple to a Y'CbCr triple. </p>
<h2 id="YCbCrToRGB">func <span>YCbCrToRGB</span> </h2> <pre data-language="go">func YCbCrToRGB(y, cb, cr uint8) (uint8, uint8, uint8)</pre> <p>YCbCrToRGB converts a Y'CbCr triple to an RGB triple. </p>
<h2 id="Alpha">type <span>Alpha</span> </h2> <p>Alpha represents an 8-bit alpha color. </p>
<pre data-language="go">type Alpha struct {
A uint8
}
</pre> <h3 id="Alpha.RGBA">func (Alpha) <span>RGBA</span> </h3> <pre data-language="go">func (c Alpha) RGBA() (r, g, b, a uint32)</pre> <h2 id="Alpha16">type <span>Alpha16</span> </h2> <p>Alpha16 represents a 16-bit alpha color. </p>
<pre data-language="go">type Alpha16 struct {
A uint16
}
</pre> <h3 id="Alpha16.RGBA">func (Alpha16) <span>RGBA</span> </h3> <pre data-language="go">func (c Alpha16) RGBA() (r, g, b, a uint32)</pre> <h2 id="CMYK">type <span>CMYK</span> <span title="Added in Go 1.5">1.5</span> </h2> <p>CMYK represents a fully opaque CMYK color, having 8 bits for each of cyan, magenta, yellow and black. </p>
<p>It is not associated with any particular color profile. </p>
<pre data-language="go">type CMYK struct {
C, M, Y, K uint8
}
</pre> <h3 id="CMYK.RGBA">func (CMYK) <span>RGBA</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (c CMYK) RGBA() (uint32, uint32, uint32, uint32)</pre> <h2 id="Color">type <span>Color</span> </h2> <p>Color can convert itself to alpha-premultiplied 16-bits per channel RGBA. The conversion may be lossy. </p>
<pre data-language="go">type Color interface {
// RGBA returns the alpha-premultiplied red, green, blue and alpha values
// for the color. Each value ranges within [0, 0xffff], but is represented
// by a uint32 so that multiplying by a blend factor up to 0xffff will not
// overflow.
//
// An alpha-premultiplied color component c has been scaled by alpha (a),
// so has valid values 0 <= c <= a.
RGBA() (r, g, b, a uint32)
}</pre> <h2 id="Gray">type <span>Gray</span> </h2> <p>Gray represents an 8-bit grayscale color. </p>
<pre data-language="go">type Gray struct {
Y uint8
}
</pre> <h3 id="Gray.RGBA">func (Gray) <span>RGBA</span> </h3> <pre data-language="go">func (c Gray) RGBA() (r, g, b, a uint32)</pre> <h2 id="Gray16">type <span>Gray16</span> </h2> <p>Gray16 represents a 16-bit grayscale color. </p>
<pre data-language="go">type Gray16 struct {
Y uint16
}
</pre> <h3 id="Gray16.RGBA">func (Gray16) <span>RGBA</span> </h3> <pre data-language="go">func (c Gray16) RGBA() (r, g, b, a uint32)</pre> <h2 id="Model">type <span>Model</span> </h2> <p>Model can convert any <a href="#Color">Color</a> to one from its own color model. The conversion may be lossy. </p>
<pre data-language="go">type Model interface {
Convert(c Color) Color
}</pre> <p>Models for the standard color types. </p>
<pre data-language="go">var (
RGBAModel Model = ModelFunc(rgbaModel)
RGBA64Model Model = ModelFunc(rgba64Model)
NRGBAModel Model = ModelFunc(nrgbaModel)
NRGBA64Model Model = ModelFunc(nrgba64Model)
AlphaModel Model = ModelFunc(alphaModel)
Alpha16Model Model = ModelFunc(alpha16Model)
GrayModel Model = ModelFunc(grayModel)
Gray16Model Model = ModelFunc(gray16Model)
)</pre> <p>CMYKModel is the <a href="#Model">Model</a> for CMYK colors. </p>
<pre data-language="go">var CMYKModel Model = ModelFunc(cmykModel)</pre> <p>NYCbCrAModel is the <a href="#Model">Model</a> for non-alpha-premultiplied Y'CbCr-with-alpha colors. </p>
<pre data-language="go">var NYCbCrAModel Model = ModelFunc(nYCbCrAModel)</pre> <p>YCbCrModel is the <a href="#Model">Model</a> for Y'CbCr colors. </p>
<pre data-language="go">var YCbCrModel Model = ModelFunc(yCbCrModel)</pre> <h3 id="ModelFunc">func <span>ModelFunc</span> </h3> <pre data-language="go">func ModelFunc(f func(Color) Color) Model</pre> <p>ModelFunc returns a <a href="#Model">Model</a> that invokes f to implement the conversion. </p>
<h2 id="NRGBA">type <span>NRGBA</span> </h2> <p>NRGBA represents a non-alpha-premultiplied 32-bit color. </p>
<pre data-language="go">type NRGBA struct {
R, G, B, A uint8
}
</pre> <h3 id="NRGBA.RGBA">func (NRGBA) <span>RGBA</span> </h3> <pre data-language="go">func (c NRGBA) RGBA() (r, g, b, a uint32)</pre> <h2 id="NRGBA64">type <span>NRGBA64</span> </h2> <p>NRGBA64 represents a non-alpha-premultiplied 64-bit color, having 16 bits for each of red, green, blue and alpha. </p>
<pre data-language="go">type NRGBA64 struct {
R, G, B, A uint16
}
</pre> <h3 id="NRGBA64.RGBA">func (NRGBA64) <span>RGBA</span> </h3> <pre data-language="go">func (c NRGBA64) RGBA() (r, g, b, a uint32)</pre> <h2 id="NYCbCrA">type <span>NYCbCrA</span> <span title="Added in Go 1.6">1.6</span> </h2> <p>NYCbCrA represents a non-alpha-premultiplied Y'CbCr-with-alpha color, having 8 bits each for one luma, two chroma and one alpha component. </p>
<pre data-language="go">type NYCbCrA struct {
YCbCr
A uint8
}
</pre> <h3 id="NYCbCrA.RGBA">func (NYCbCrA) <span>RGBA</span> <span title="Added in Go 1.6">1.6</span> </h3> <pre data-language="go">func (c NYCbCrA) RGBA() (uint32, uint32, uint32, uint32)</pre> <h2 id="Palette">type <span>Palette</span> </h2> <p>Palette is a palette of colors. </p>
<pre data-language="go">type Palette []Color</pre> <h3 id="Palette.Convert">func (Palette) <span>Convert</span> </h3> <pre data-language="go">func (p Palette) Convert(c Color) Color</pre> <p>Convert returns the palette color closest to c in Euclidean R,G,B space. </p>
<h3 id="Palette.Index">func (Palette) <span>Index</span> </h3> <pre data-language="go">func (p Palette) Index(c Color) int</pre> <p>Index returns the index of the palette color closest to c in Euclidean R,G,B,A space. </p>
<h2 id="RGBA">type <span>RGBA</span> </h2> <p>RGBA represents a traditional 32-bit alpha-premultiplied color, having 8 bits for each of red, green, blue and alpha. </p>
<p>An alpha-premultiplied color component C has been scaled by alpha (A), so has valid values 0 <= C <= A. </p>
<pre data-language="go">type RGBA struct {
R, G, B, A uint8
}
</pre> <h3 id="RGBA.RGBA">func (RGBA) <span>RGBA</span> </h3> <pre data-language="go">func (c RGBA) RGBA() (r, g, b, a uint32)</pre> <h2 id="RGBA64">type <span>RGBA64</span> </h2> <p>RGBA64 represents a 64-bit alpha-premultiplied color, having 16 bits for each of red, green, blue and alpha. </p>
<p>An alpha-premultiplied color component C has been scaled by alpha (A), so has valid values 0 <= C <= A. </p>
<pre data-language="go">type RGBA64 struct {
R, G, B, A uint16
}
</pre> <h3 id="RGBA64.RGBA">func (RGBA64) <span>RGBA</span> </h3> <pre data-language="go">func (c RGBA64) RGBA() (r, g, b, a uint32)</pre> <h2 id="YCbCr">type <span>YCbCr</span> </h2> <p>YCbCr represents a fully opaque 24-bit Y'CbCr color, having 8 bits each for one luma and two chroma components. </p>
<p>JPEG, VP8, the MPEG family and other codecs use this color model. Such codecs often use the terms YUV and Y'CbCr interchangeably, but strictly speaking, the term YUV applies only to analog video signals, and Y' (luma) is Y (luminance) after applying gamma correction. </p>
<p>Conversion between RGB and Y'CbCr is lossy and there are multiple, slightly different formulae for converting between the two. This package follows the JFIF specification at <a href="https://www.w3.org/Graphics/JPEG/jfif3.pdf">https://www.w3.org/Graphics/JPEG/jfif3.pdf</a>. </p>
<pre data-language="go">type YCbCr struct {
Y, Cb, Cr uint8
}
</pre> <h3 id="YCbCr.RGBA">func (YCbCr) <span>RGBA</span> </h3> <pre data-language="go">func (c YCbCr) RGBA() (uint32, uint32, uint32, uint32)</pre> <h2 id="pkg-subdirectories">Subdirectories</h2> <div class="pkg-dir"> <table> <tr> <th class="pkg-name">Name</th> <th class="pkg-synopsis">Synopsis</th> </tr> <tr> <td colspan="2"><a href="../index">..</a></td> </tr> <tr> <td class="pkg-name"> <a href="palette/index">palette</a> </td> <td class="pkg-synopsis"> Package palette provides standard color palettes. </td> </tr> </table> </div><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/color/" class="_attribution-link">http://golang.org/pkg/image/color/</a>
</p>
</div>
|