<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                # package image `import "image"` image實現了基本的2D圖片庫。 基本接口叫作Image。圖片的色彩定義在image/color包。 Image接口可以通過調用如NewRGBA和NewPaletted函數等獲得;也可以通過調用Decode函數解碼包含GIF、JPEG或PNG格式圖像數據的輸入流獲得。解碼任何具體圖像類型之前都必須注冊對應類型的解碼函數。注冊過程一般是作為包初始化的副作用,放在包的init函數里。因此,要解碼PNG圖像,只需在程序的main包里嵌入如下代碼: ``` import _ "image/png" ``` \_表示導入包但不使用包中的變量/函數/類型,只是為了包初始化函數的副作用。 參見[http://golang.org/doc/articles/image_package.html](http://golang.org/doc/articles/image_package.html) Example ``` // This example demonstrates decoding a JPEG image and examining its pixels. package image_test import ( "encoding/base64" "fmt" "image" "log" "strings" // Package image/jpeg is not used explicitly in the code below, // but is imported for its initialization side-effect, which allows // image.Decode to understand JPEG formatted images. Uncomment these // two lines to also understand GIF and PNG images: // _ "image/gif" // _ "image/png" _ "image/jpeg" ) func Example() { // Decode the JPEG data. If reading from file, create a reader with // // reader, err := os.Open("testdata/video-001.q50.420.jpeg") // if err != nil { // log.Fatal(err) // } // defer reader.Close() reader := base64.NewDecoder(base64.StdEncoding, strings.NewReader(data)) m, _, err := image.Decode(reader) if err != nil { log.Fatal(err) } bounds := m.Bounds() // Calculate a 16-bin histogram for m's red, green, blue and alpha components. // // An image's bounds do not necessarily start at (0, 0), so the two loops start // at bounds.Min.Y and bounds.Min.X. Looping over Y first and X second is more // likely to result in better memory access patterns than X first and Y second. var histogram [16][4]int for y := bounds.Min.Y; y < bounds.Max.Y; y++ { for x := bounds.Min.X; x < bounds.Max.X; x++ { r, g, b, a := m.At(x, y).RGBA() // A color's RGBA method returns values in the range [0, 65535]. // Shifting by 12 reduces this to the range [0, 15]. histogram[r>>12][0]++ histogram[g>>12][1]++ histogram[b>>12][2]++ histogram[a>>12][3]++ } } // Print the results. fmt.Printf("%-14s %6s %6s %6s %6s\n", "bin", "red", "green", "blue", "alpha") for i, x := range histogram { fmt.Printf("0x%04x-0x%04x: %6d %6d %6d %6d\n", i<<12, (i+1)<<12-1, x[0], x[1], x[2], x[3]) } // Output: // bin red green blue alpha // 0x0000-0x0fff: 353 759 7228 0 // 0x1000-0x1fff: 629 2944 1036 0 // 0x2000-0x2fff: 1075 2319 984 0 // 0x3000-0x3fff: 838 2291 988 0 // 0x4000-0x4fff: 540 1302 542 0 // 0x5000-0x5fff: 319 971 263 0 // 0x6000-0x6fff: 316 377 178 0 // 0x7000-0x7fff: 581 280 216 0 // 0x8000-0x8fff: 3457 228 274 0 // 0x9000-0x9fff: 2294 237 334 0 // 0xa000-0xafff: 938 283 370 0 // 0xb000-0xbfff: 322 338 401 0 // 0xc000-0xcfff: 229 386 295 0 // 0xd000-0xdfff: 263 416 281 0 // 0xe000-0xefff: 538 433 312 0 // 0xf000-0xffff: 2758 1886 1748 15450 } const data = ` /9j/4AAQSkZJRgABAQIAHAAcAAD/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdA SFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2N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UVnLY0iEsUipG7rhZBlDkc1HgYoorM 0HwyBXGeRjmrcUhMg2ghezd//rUUVcTKW5s2jZtY/QDaOKKKK8ip8bPRj8KP/9k= ` ``` ## Index * [Variables](#pkg-variables) * [type Image](#Image) * [func Decode(r io.Reader) (Image, string, error)](#Decode) * [type PalettedImage](#PalettedImage) * [type Config](#Config) * [func DecodeConfig(r io.Reader) (Config, string, error)](#DecodeConfig) * [func RegisterFormat(name, magic string, decode func(io.Reader) (Image, error), decodeConfig func(io.Reader) (Config, error))](#RegisterFormat) * [type Point](#Point) * [func Pt(X, Y int) Point](#Pt) * [func (p Point) Eq(q Point) bool](#Point.Eq) * [func (p Point) Add(q Point) Point](#Point.Add) * [func (p Point) Sub(q Point) Point](#Point.Sub) * [func (p Point) Mul(k int) Point](#Point.Mul) * [func (p Point) Div(k int) Point](#Point.Div) * [func (p Point) In(r Rectangle) bool](#Point.In) * [func (p Point) Mod(r Rectangle) Point](#Point.Mod) * [func (p Point) String() string](#Point.String) * [type Rectangle](#Rectangle) * [func Rect(x0, y0, x1, y1 int) Rectangle](#Rect) * [func (r Rectangle) Canon() Rectangle](#Rectangle.Canon) * [func (r Rectangle) Dx() int](#Rectangle.Dx) * [func (r Rectangle) Dy() int](#Rectangle.Dy) * [func (r Rectangle) Size() Point](#Rectangle.Size) * [func (r Rectangle) Empty() bool](#Rectangle.Empty) * [func (r Rectangle) Eq(s Rectangle) bool](#Rectangle.Eq) * [func (r Rectangle) In(s Rectangle) bool](#Rectangle.In) * [func (r Rectangle) Overlaps(s Rectangle) bool](#Rectangle.Overlaps) * [func (r Rectangle) Add(p Point) Rectangle](#Rectangle.Add) * [func (r Rectangle) Sub(p Point) Rectangle](#Rectangle.Sub) * [func (r Rectangle) Intersect(s Rectangle) Rectangle](#Rectangle.Intersect) * [func (r Rectangle) Union(s Rectangle) Rectangle](#Rectangle.Union) * [func (r Rectangle) Inset(n int) Rectangle](#Rectangle.Inset) * [func (r Rectangle) String() string](#Rectangle.String) * [type Uniform](#Uniform) * [func NewUniform(c color.Color) \*Uniform](#NewUniform) * [func (c \*Uniform) At(x, y int) color.Color](#Uniform.At) * [func (c \*Uniform) Bounds() Rectangle](#Uniform.Bounds) * [func (c \*Uniform) ColorModel() color.Model](#Uniform.ColorModel) * [func (c \*Uniform) Convert(color.Color) color.Color](#Uniform.Convert) * [func (c \*Uniform) Opaque() bool](#Uniform.Opaque) * [func (c \*Uniform) RGBA() (r, g, b, a uint32)](#Uniform.RGBA) * [type Alpha](#Alpha) * [func NewAlpha(r Rectangle) \*Alpha](#NewAlpha) * [func (p \*Alpha) At(x, y int) color.Color](#Alpha.At) * [func (p \*Alpha) Bounds() Rectangle](#Alpha.Bounds) * [func (p \*Alpha) ColorModel() color.Model](#Alpha.ColorModel) * [func (p \*Alpha) Opaque() bool](#Alpha.Opaque) * [func (p \*Alpha) PixOffset(x, y int) int](#Alpha.PixOffset) * [func (p \*Alpha) Set(x, y int, c color.Color)](#Alpha.Set) * [func (p \*Alpha) SetAlpha(x, y int, c color.Alpha)](#Alpha.SetAlpha) * [func (p \*Alpha) SubImage(r Rectangle) Image](#Alpha.SubImage) * [type Alpha16](#Alpha16) * [func NewAlpha16(r Rectangle) \*Alpha16](#NewAlpha16) * [func (p \*Alpha16) At(x, y int) color.Color](#Alpha16.At) * [func (p \*Alpha16) Bounds() Rectangle](#Alpha16.Bounds) * [func (p \*Alpha16) ColorModel() color.Model](#Alpha16.ColorModel) * [func (p \*Alpha16) Opaque() bool](#Alpha16.Opaque) * [func (p \*Alpha16) PixOffset(x, y int) int](#Alpha16.PixOffset) * [func (p \*Alpha16) Set(x, y int, c color.Color)](#Alpha16.Set) * [func (p \*Alpha16) SetAlpha16(x, y int, c color.Alpha16)](#Alpha16.SetAlpha16) * [func (p \*Alpha16) SubImage(r Rectangle) Image](#Alpha16.SubImage) * [type Gray](#Gray) * [func NewGray(r Rectangle) \*Gray](#NewGray) * [func (p \*Gray) At(x, y int) color.Color](#Gray.At) * [func (p \*Gray) Bounds() Rectangle](#Gray.Bounds) * [func (p \*Gray) ColorModel() color.Model](#Gray.ColorModel) * [func (p \*Gray) Opaque() bool](#Gray.Opaque) * [func (p \*Gray) PixOffset(x, y int) int](#Gray.PixOffset) * [func (p \*Gray) Set(x, y int, c color.Color)](#Gray.Set) * [func (p \*Gray) SetGray(x, y int, c color.Gray)](#Gray.SetGray) * [func (p \*Gray) SubImage(r Rectangle) Image](#Gray.SubImage) * [type Gray16](#Gray16) * [func NewGray16(r Rectangle) \*Gray16](#NewGray16) * [func (p \*Gray16) At(x, y int) color.Color](#Gray16.At) * [func (p \*Gray16) Bounds() Rectangle](#Gray16.Bounds) * [func (p \*Gray16) ColorModel() color.Model](#Gray16.ColorModel) * [func (p \*Gray16) Opaque() bool](#Gray16.Opaque) * [func (p \*Gray16) PixOffset(x, y int) int](#Gray16.PixOffset) * [func (p \*Gray16) Set(x, y int, c color.Color)](#Gray16.Set) * [func (p \*Gray16) SetGray16(x, y int, c color.Gray16)](#Gray16.SetGray16) * [func (p \*Gray16) SubImage(r Rectangle) Image](#Gray16.SubImage) * [type RGBA](#RGBA) * [func NewRGBA(r Rectangle) \*RGBA](#NewRGBA) * [func (p \*RGBA) At(x, y int) color.Color](#RGBA.At) * [func (p \*RGBA) Bounds() Rectangle](#RGBA.Bounds) * [func (p \*RGBA) ColorModel() color.Model](#RGBA.ColorModel) * [func (p \*RGBA) Opaque() bool](#RGBA.Opaque) * [func (p \*RGBA) PixOffset(x, y int) int](#RGBA.PixOffset) * [func (p \*RGBA) Set(x, y int, c color.Color)](#RGBA.Set) * [func (p \*RGBA) SetRGBA(x, y int, c color.RGBA)](#RGBA.SetRGBA) * [func (p \*RGBA) SubImage(r Rectangle) Image](#RGBA.SubImage) * [type RGBA64](#RGBA64) * [func NewRGBA64(r Rectangle) \*RGBA64](#NewRGBA64) * [func (p \*RGBA64) At(x, y int) color.Color](#RGBA64.At) * [func (p \*RGBA64) Bounds() Rectangle](#RGBA64.Bounds) * [func (p \*RGBA64) ColorModel() color.Model](#RGBA64.ColorModel) * [func (p \*RGBA64) Opaque() bool](#RGBA64.Opaque) * [func (p \*RGBA64) PixOffset(x, y int) int](#RGBA64.PixOffset) * [func (p \*RGBA64) Set(x, y int, c color.Color)](#RGBA64.Set) * [func (p \*RGBA64) SetRGBA64(x, y int, c color.RGBA64)](#RGBA64.SetRGBA64) * [func (p \*RGBA64) SubImage(r Rectangle) Image](#RGBA64.SubImage) * [type NRGBA](#NRGBA) * [func NewNRGBA(r Rectangle) \*NRGBA](#NewNRGBA) * [func (p \*NRGBA) At(x, y int) color.Color](#NRGBA.At) * [func (p \*NRGBA) Bounds() Rectangle](#NRGBA.Bounds) * [func (p \*NRGBA) ColorModel() color.Model](#NRGBA.ColorModel) * [func (p \*NRGBA) Opaque() bool](#NRGBA.Opaque) * [func (p \*NRGBA) PixOffset(x, y int) int](#NRGBA.PixOffset) * [func (p \*NRGBA) Set(x, y int, c color.Color)](#NRGBA.Set) * [func (p \*NRGBA) SetNRGBA(x, y int, c color.NRGBA)](#NRGBA.SetNRGBA) * [func (p \*NRGBA) SubImage(r Rectangle) Image](#NRGBA.SubImage) * [type NRGBA64](#NRGBA64) * [func NewNRGBA64(r Rectangle) \*NRGBA64](#NewNRGBA64) * [func (p \*NRGBA64) At(x, y int) color.Color](#NRGBA64.At) * [func (p \*NRGBA64) Bounds() Rectangle](#NRGBA64.Bounds) * [func (p \*NRGBA64) ColorModel() color.Model](#NRGBA64.ColorModel) * [func (p \*NRGBA64) Opaque() bool](#NRGBA64.Opaque) * [func (p \*NRGBA64) PixOffset(x, y int) int](#NRGBA64.PixOffset) * [func (p \*NRGBA64) Set(x, y int, c color.Color)](#NRGBA64.Set) * [func (p \*NRGBA64) SetNRGBA64(x, y int, c color.NRGBA64)](#NRGBA64.SetNRGBA64) * [func (p \*NRGBA64) SubImage(r Rectangle) Image](#NRGBA64.SubImage) * [type Paletted](#Paletted) * [func NewPaletted(r Rectangle, p color.Palette) \*Paletted](#NewPaletted) * [func (p \*Paletted) At(x, y int) color.Color](#Paletted.At) * [func (p \*Paletted) Bounds() Rectangle](#Paletted.Bounds) * [func (p \*Paletted) ColorIndexAt(x, y int) uint8](#Paletted.ColorIndexAt) * [func (p \*Paletted) ColorModel() color.Model](#Paletted.ColorModel) * [func (p \*Paletted) Opaque() bool](#Paletted.Opaque) * [func (p \*Paletted) PixOffset(x, y int) int](#Paletted.PixOffset) * [func (p \*Paletted) Set(x, y int, c color.Color)](#Paletted.Set) * [func (p \*Paletted) SetColorIndex(x, y int, index uint8)](#Paletted.SetColorIndex) * [func (p \*Paletted) SubImage(r Rectangle) Image](#Paletted.SubImage) * [type YCbCrSubsampleRatio](#YCbCrSubsampleRatio) * [func (s YCbCrSubsampleRatio) String() string](#YCbCrSubsampleRatio.String) * [type YCbCr](#YCbCr) * [func NewYCbCr(r Rectangle, subsampleRatio YCbCrSubsampleRatio) \*YCbCr](#NewYCbCr) * [func (p \*YCbCr) At(x, y int) color.Color](#YCbCr.At) * [func (p \*YCbCr) Bounds() Rectangle](#YCbCr.Bounds) * [func (p \*YCbCr) COffset(x, y int) int](#YCbCr.COffset) * [func (p \*YCbCr) ColorModel() color.Model](#YCbCr.ColorModel) * [func (p \*YCbCr) Opaque() bool](#YCbCr.Opaque) * [func (p \*YCbCr) SubImage(r Rectangle) Image](#YCbCr.SubImage) * [func (p \*YCbCr) YOffset(x, y int) int](#YCbCr.YOffset) ### Examples * [package](#example-package) ## Variables ``` var ( // Black是一個完全不透明的面積無限大的黑色圖像 Black = NewUniform(color.Black) // White是一個完全不透明的面積無限大的白色圖像 White = NewUniform(color.White) // Transparent是一個完全透明的面積無限大的圖像 Transparent = NewUniform(color.Transparent) // Opaque是一個完全不透明的面積無限大的圖像 Opaque = NewUniform(color.Opaque) ) ``` ``` var ErrFormat = errors.New("image: unknown format") ``` ErrFormat說明解碼時遇到了未知的格式。 ## type [Image](https://github.com/golang/go/blob/master/src/image/image.go#L36 "View Source") ``` type Image interface { // ColorModel方法返回圖像的色彩模型 ColorModel() color.Model // Bounds方法返回圖像的范圍,范圍不一定包括點(0, 0) Bounds() Rectangle // At方法返回(x, y)位置的色彩 // At(Bounds().Min.X, Bounds().Min.Y)返回網格左上角像素的色彩 // At(Bounds().Max.X-1, Bounds().Max.Y-1)?返回網格右下角像素的色彩 At(x, y int) color.Color } ``` Image接口表示一個采用某色彩模型的顏色構成的有限矩形網格(即一幅圖像)。 ### func [Decode](https://github.com/golang/go/blob/master/src/image/format.go#L78 "View Source") ``` func Decode(r io.Reader) (Image, string, error) ``` DecodeConfig函數解碼并返回一個采用某種已注冊格式編碼的圖像。字符串返回值是該格式注冊時的名字。格式一般是在該編碼格式的包的init函數中注冊的。 ## type [PalettedImage](https://github.com/golang/go/blob/master/src/image/image.go#L53 "View Source") ``` type PalettedImage interface { // ColorIndexAt方法返回(x, y)位置的像素的(調色板)索引 ColorIndexAt(x, y int) uint8 Image } ``` PalettedImage接口代表一幅圖像,它的像素可能來自一個有限的調色板。 如果有對象m滿足PalettedImage接口,且m.ColorModel()返回的color.Model接口底層為一個Palette類型值(記為p),則m.At(x, y)返回值應等于p[m.ColorIndexAt(x, y)]。如果m的色彩模型不是Palette,則ColorIndexAt的行為是不確定的。 ## type [Config](https://github.com/golang/go/blob/master/src/image/image.go#L29 "View Source") ``` type Config struct { ColorModel color.Model Width, Height int } ``` Config保管圖像的色彩模型和尺寸信息。 ### func [DecodeConfig](https://github.com/golang/go/blob/master/src/image/format.go#L92 "View Source") ``` func DecodeConfig(r io.Reader) (Config, string, error) ``` DecodeConfig函數解碼并返回一個采用某種已注冊格式編碼的圖像的色彩模型和尺寸。字符串返回值是該格式注冊時的名字。格式一般是在該編碼格式的包的init函數中注冊的。 ## func [RegisterFormat](https://github.com/golang/go/blob/master/src/image/format.go#L32 "View Source") ``` func RegisterFormat(name, magic string, decode func(io.Reader) (Image, error), decodeConfig func(io.Reader) (Config, error)) ``` RegisterFormat注冊一個供Decode函數使用的圖片格式。name是格式的名字,如"jpeg"或"png";magic是該格式編碼的魔術前綴,該字符串可以包含"?"通配符,每個通配符匹配一個字節;decode函數用于解碼圖片;decodeConfig函數只解碼圖片的配置。 ## type [Point](https://github.com/golang/go/blob/master/src/image/geom.go#L12 "View Source") ``` type Point struct { X, Y int } ``` Point是X, Y坐標對。坐標軸是向右(X)向下(Y)的。既可以表示點,也可以表示向量。 ``` var ZP Point ``` ZP是原點。 ### func [Pt](https://github.com/golang/go/blob/master/src/image/geom.go#L72 "View Source") ``` func Pt(X, Y int) Point ``` 返回Point{X , Y} ### func (Point) [Eq](https://github.com/golang/go/blob/master/src/image/geom.go#L64 "View Source") ``` func (p Point) Eq(q Point) bool ``` 報告p和q是否相同。 ### func (Point) [Add](https://github.com/golang/go/blob/master/src/image/geom.go#L22 "View Source") ``` func (p Point) Add(q Point) Point ``` 返回點Point{p.X+q.X, p.Y+q.Y} ### func (Point) [Sub](https://github.com/golang/go/blob/master/src/image/geom.go#L27 "View Source") ``` func (p Point) Sub(q Point) Point ``` 返回點Point{p.X-q.X, p.Y-q.Y} ### func (Point) [Mul](https://github.com/golang/go/blob/master/src/image/geom.go#L32 "View Source") ``` func (p Point) Mul(k int) Point ``` 返回點Point{p.X\*k, p.Y\*k} ### func (Point) [Div](https://github.com/golang/go/blob/master/src/image/geom.go#L37 "View Source") ``` func (p Point) Div(k int) Point ``` 返回點Point{p.X/k, p.Y/k } ### func (Point) [In](https://github.com/golang/go/blob/master/src/image/geom.go#L42 "View Source") ``` func (p Point) In(r Rectangle) bool ``` 報告p是否在r范圍內。 ### func (Point) [Mod](https://github.com/golang/go/blob/master/src/image/geom.go#L49 "View Source") ``` func (p Point) Mod(r Rectangle) Point ``` 返回r范圍內的某點q,滿足p.X-q.X是r寬度的倍數,p.Y-q.Y是r高度的倍數。 ### func (Point) [String](https://github.com/golang/go/blob/master/src/image/geom.go#L17 "View Source") ``` func (p Point) String() string ``` 返回p的字符串表示。格式為"(3,4)" ## type [Rectangle](https://github.com/golang/go/blob/master/src/image/geom.go#L80 "View Source") ``` type Rectangle struct { Min, Max Point } ``` Rectangle代表一個矩形。該矩形包含所有滿足Min.X &lt;= X &lt; Max.X且Min.Y &lt;= Y &lt; Max.Y的點。如果兩個字段滿足Min.X &lt;= Max.X且Min.Y &lt;= Max.Y,就稱該實例為規范格式的。矩形的方法,當輸入是規范格式時,總是返回規范格式的輸出。 ``` var ZR Rectangle ``` ZR是矩形的零值。 ### func [Rect](https://github.com/golang/go/blob/master/src/image/geom.go#L226 "View Source") ``` func Rect(x0, y0, x1, y1 int) Rectangle ``` 返回一個矩形Rectangle{Pt(x0, y0), Pt(x1, y1)}。 ### func (Rectangle) [Canon](https://github.com/golang/go/blob/master/src/image/geom.go#L212 "View Source") ``` func (r Rectangle) Canon() Rectangle ``` 返回矩形的規范版本(左上&右下),方法必要時會交換坐標的最大值和最小值。 ### func (Rectangle) [Dx](https://github.com/golang/go/blob/master/src/image/geom.go#L90 "View Source") ``` func (r Rectangle) Dx() int ``` 返回r的寬度。 ### func (Rectangle) [Dy](https://github.com/golang/go/blob/master/src/image/geom.go#L95 "View Source") ``` func (r Rectangle) Dy() int ``` 返回r的高度。 ### func (Rectangle) [Size](https://github.com/golang/go/blob/master/src/image/geom.go#L100 "View Source") ``` func (r Rectangle) Size() Point ``` 返回r的寬度w和高度h構成的點Point{w, h}。 ### func (Rectangle) [Empty](https://github.com/golang/go/blob/master/src/image/geom.go#L183 "View Source") ``` func (r Rectangle) Empty() bool ``` 報告矩形是否為空矩形。(即內部不包含點的矩形) ### func (Rectangle) [Eq](https://github.com/golang/go/blob/master/src/image/geom.go#L188 "View Source") ``` func (r Rectangle) Eq(s Rectangle) bool ``` 報告兩個矩形是否相同。 ### func (Rectangle) [In](https://github.com/golang/go/blob/master/src/image/geom.go#L200 "View Source") ``` func (r Rectangle) In(s Rectangle) bool ``` 如果r包含的所有點都在s內,則返回真;否則返回假。 ### func (Rectangle) [Overlaps](https://github.com/golang/go/blob/master/src/image/geom.go#L194 "View Source") ``` func (r Rectangle) Overlaps(s Rectangle) bool ``` 如果r和s有非空的交集,則返回真;否則返回假。 ### func (Rectangle) [Add](https://github.com/golang/go/blob/master/src/image/geom.go#L108 "View Source") ``` func (r Rectangle) Add(p Point) Rectangle ``` 返回矩形按p(作為向量)平移后的新矩形。 ### func (Rectangle) [Sub](https://github.com/golang/go/blob/master/src/image/geom.go#L116 "View Source") ``` func (r Rectangle) Sub(p Point) Rectangle ``` 返回矩形按p(作為向量)反向平移后的新矩形。 ### func (Rectangle) [Intersect](https://github.com/golang/go/blob/master/src/image/geom.go#L146 "View Source") ``` func (r Rectangle) Intersect(s Rectangle) Rectangle ``` 返回兩個矩形的交集矩形(同時被r和s包含的最大矩形);如果r和s沒有重疊會返回Rectangle零值。 ### func (Rectangle) [Union](https://github.com/golang/go/blob/master/src/image/geom.go#L166 "View Source") ``` func (r Rectangle) Union(s Rectangle) Rectangle ``` 返回同時包含r和s的最小矩形。 ### func (Rectangle) [Inset](https://github.com/golang/go/blob/master/src/image/geom.go#L126 "View Source") ``` func (r Rectangle) Inset(n int) Rectangle ``` 返回去掉矩形四周寬度n的框的矩形,n可為負數。如果n過大將返回靠近r中心位置的空矩形。 ### func (Rectangle) [String](https://github.com/golang/go/blob/master/src/image/geom.go#L85 "View Source") ``` func (r Rectangle) String() string ``` 返回矩形的字符串表示,格式為"(3,4)-(6,5)"。 ## type [Uniform](https://github.com/golang/go/blob/master/src/image/names.go#L24 "View Source") ``` type Uniform struct { C color.Color } ``` Uniform類型代表一塊面積無限大的具有同一色彩的圖像。它實現了color.Color、color.Model和Image等接口。 ### func [NewUniform](https://github.com/golang/go/blob/master/src/image/names.go#L50 "View Source") ``` func NewUniform(c color.Color) *Uniform ``` ### func (\*Uniform) [At](https://github.com/golang/go/blob/master/src/image/names.go#L42 "View Source") ``` func (c *Uniform) At(x, y int) color.Color ``` ### func (\*Uniform) [Bounds](https://github.com/golang/go/blob/master/src/image/names.go#L40 "View Source") ``` func (c *Uniform) Bounds() Rectangle ``` ### func (\*Uniform) [ColorModel](https://github.com/golang/go/blob/master/src/image/names.go#L32 "View Source") ``` func (c *Uniform) ColorModel() color.Model ``` ### func (\*Uniform) [Convert](https://github.com/golang/go/blob/master/src/image/names.go#L36 "View Source") ``` func (c *Uniform) Convert(color.Color) color.Color ``` ### func (\*Uniform) [Opaque](https://github.com/golang/go/blob/master/src/image/names.go#L45 "View Source") ``` func (c *Uniform) Opaque() bool ``` Opaque方法掃描整個圖像并報告該圖像是否是完全不透明的。 ### func (\*Uniform) [RGBA](https://github.com/golang/go/blob/master/src/image/names.go#L28 "View Source") ``` func (c *Uniform) RGBA() (r, g, b, a uint32) ``` ## type [Alpha](https://github.com/golang/go/blob/master/src/image/image.go#L466 "View Source") ``` type Alpha struct { // Pix保管圖像的像素,內容為alpha通道值(即透明度)。 // 像素(x, y)起始位置是Pix[(y-Rect.Min.Y)*Stride + (x-Rect.Min.X)*1] Pix []uint8 // Stride是Pix中每行像素占用的字節數 Stride int // Rect是圖像的范圍 Rect Rectangle } ``` Alpha類型代表一幅內存中的圖像,其At方法返回color.Alpha類型的值。 ### func [NewAlpha](https://github.com/golang/go/blob/master/src/image/image.go#L547 "View Source") ``` func NewAlpha(r Rectangle) *Alpha ``` NewAlpha函數創建并返回一個具有指定寬度和高度的Alpha。 ### func (\*Alpha) [At](https://github.com/golang/go/blob/master/src/image/image.go#L480 "View Source") ``` func (p *Alpha) At(x, y int) color.Color ``` ### func (\*Alpha) [Bounds](https://github.com/golang/go/blob/master/src/image/image.go#L478 "View Source") ``` func (p *Alpha) Bounds() Rectangle ``` ### func (\*Alpha) [ColorModel](https://github.com/golang/go/blob/master/src/image/image.go#L476 "View Source") ``` func (p *Alpha) ColorModel() color.Model ``` ### func (\*Alpha) [Opaque](https://github.com/golang/go/blob/master/src/image/image.go#L529 "View Source") ``` func (p *Alpha) Opaque() bool ``` Opaque方法掃描整個圖像并報告圖像是否是完全不透明的。 ### func (\*Alpha) [PixOffset](https://github.com/golang/go/blob/master/src/image/image.go#L490 "View Source") ``` func (p *Alpha) PixOffset(x, y int) int ``` PixOffset方法返回像素(x, y)的數據起始位置在Pix字段的偏移量/索引。 ### func (\*Alpha) [Set](https://github.com/golang/go/blob/master/src/image/image.go#L494 "View Source") ``` func (p *Alpha) Set(x, y int, c color.Color) ``` ### func (\*Alpha) [SetAlpha](https://github.com/golang/go/blob/master/src/image/image.go#L502 "View Source") ``` func (p *Alpha) SetAlpha(x, y int, c color.Alpha) ``` ### func (\*Alpha) [SubImage](https://github.com/golang/go/blob/master/src/image/image.go#L512 "View Source") ``` func (p *Alpha) SubImage(r Rectangle) Image ``` SubImage方法返回代表原圖像一部分(r的范圍)的新圖像。返回值和原圖像的像素數據是共用的。 ## type [Alpha16](https://github.com/golang/go/blob/master/src/image/image.go#L554 "View Source") ``` type Alpha16 struct { // Pix保管圖像的像素,內容為alpha通道值(即透明度,大端在前的格式)。 // 像素(x, y)起始位置是Pix[(y-Rect.Min.Y)*Stride + (x-Rect.Min.X)*2] Pix []uint8 // Stride是Pix中每行像素占用的字節數 Stride int // Rect是圖像的范圍 Rect Rectangle } ``` Alpha16類型代表一幅內存中的圖像,其At方法返回color.Alpha16類型的值。 ### func [NewAlpha16](https://github.com/golang/go/blob/master/src/image/image.go#L638 "View Source") ``` func NewAlpha16(r Rectangle) *Alpha16 ``` NewAlpha16函數創建并返回一個具有指定范圍的Alpha16。 ### func (\*Alpha16) [At](https://github.com/golang/go/blob/master/src/image/image.go#L568 "View Source") ``` func (p *Alpha16) At(x, y int) color.Color ``` ### func (\*Alpha16) [Bounds](https://github.com/golang/go/blob/master/src/image/image.go#L566 "View Source") ``` func (p *Alpha16) Bounds() Rectangle ``` ### func (\*Alpha16) [ColorModel](https://github.com/golang/go/blob/master/src/image/image.go#L564 "View Source") ``` func (p *Alpha16) ColorModel() color.Model ``` ### func (\*Alpha16) [Opaque](https://github.com/golang/go/blob/master/src/image/image.go#L620 "View Source") ``` func (p *Alpha16) Opaque() bool ``` Opaque方法掃描整個圖像并報告圖像是否是完全不透明的。 ### func (\*Alpha16) [PixOffset](https://github.com/golang/go/blob/master/src/image/image.go#L578 "View Source") ``` func (p *Alpha16) PixOffset(x, y int) int ``` PixOffset方法返回像素(x, y)的數據起始位置在Pix字段的偏移量/索引。 ### func (\*Alpha16) [Set](https://github.com/golang/go/blob/master/src/image/image.go#L582 "View Source") ``` func (p *Alpha16) Set(x, y int, c color.Color) ``` ### func (\*Alpha16) [SetAlpha16](https://github.com/golang/go/blob/master/src/image/image.go#L592 "View Source") ``` func (p *Alpha16) SetAlpha16(x, y int, c color.Alpha16) ``` ### func (\*Alpha16) [SubImage](https://github.com/golang/go/blob/master/src/image/image.go#L603 "View Source") ``` func (p *Alpha16) SubImage(r Rectangle) Image ``` SubImage方法返回代表原圖像一部分(r的范圍)的新圖像。返回值和原圖像的像素數據是共用的。 ## type [Gray](https://github.com/golang/go/blob/master/src/image/image.go#L645 "View Source") ``` type Gray struct { // Pix保管圖像的像素,內容為灰度。 // 像素(x, y)起始位置是Pix[(y-Rect.Min.Y)*Stride + (x-Rect.Min.X)*1] Pix []uint8 // Stride是Pix中每行像素占用的字節數 Stride int // Rect是圖像的范圍 Rect Rectangle } ``` Gray類型代表一幅內存中的圖像,其At方法返回color.Gray類型的值。 ### func [NewGray](https://github.com/golang/go/blob/master/src/image/image.go#L713 "View Source") ``` func NewGray(r Rectangle) *Gray ``` NewGray函數創建并返回一個具有指定范圍的Gray。 ### func (\*Gray) [At](https://github.com/golang/go/blob/master/src/image/image.go#L659 "View Source") ``` func (p *Gray) At(x, y int) color.Color ``` ### func (\*Gray) [Bounds](https://github.com/golang/go/blob/master/src/image/image.go#L657 "View Source") ``` func (p *Gray) Bounds() Rectangle ``` ### func (\*Gray) [ColorModel](https://github.com/golang/go/blob/master/src/image/image.go#L655 "View Source") ``` func (p *Gray) ColorModel() color.Model ``` ### func (\*Gray) [Opaque](https://github.com/golang/go/blob/master/src/image/image.go#L708 "View Source") ``` func (p *Gray) Opaque() bool ``` Opaque方法掃描整個圖像并報告圖像是否是完全不透明的。 ### func (\*Gray) [PixOffset](https://github.com/golang/go/blob/master/src/image/image.go#L669 "View Source") ``` func (p *Gray) PixOffset(x, y int) int ``` PixOffset方法返回像素(x, y)的數據起始位置在Pix字段的偏移量/索引。 ### func (\*Gray) [Set](https://github.com/golang/go/blob/master/src/image/image.go#L673 "View Source") ``` func (p *Gray) Set(x, y int, c color.Color) ``` ### func (\*Gray) [SetGray](https://github.com/golang/go/blob/master/src/image/image.go#L681 "View Source") ``` func (p *Gray) SetGray(x, y int, c color.Gray) ``` ### func (\*Gray) [SubImage](https://github.com/golang/go/blob/master/src/image/image.go#L691 "View Source") ``` func (p *Gray) SubImage(r Rectangle) Image ``` SubImage方法返回代表原圖像一部分(r的范圍)的新圖像。返回值和原圖像的像素數據是共用的。 ## type [Gray16](https://github.com/golang/go/blob/master/src/image/image.go#L720 "View Source") ``` type Gray16 struct { // Pix保管圖像的像素,內容為灰度(大端在前的格式)。 // 像素(x, y)起始位置是Pix[(y-Rect.Min.Y)*Stride + (x-Rect.Min.X)*2] Pix []uint8 // Stride是Pix中每行像素占用的字節數 Stride int // Rect是圖像的范圍 Rect Rectangle } ``` Gray16類型代表一幅內存中的圖像,其At方法返回color.Gray16類型的值。 ### func [NewGray16](https://github.com/golang/go/blob/master/src/image/image.go#L791 "View Source") ``` func NewGray16(r Rectangle) *Gray16 ``` NewGray16函數創建并返回一個具有指定范圍的Gray16。 ### func (\*Gray16) [At](https://github.com/golang/go/blob/master/src/image/image.go#L734 "View Source") ``` func (p *Gray16) At(x, y int) color.Color ``` ### func (\*Gray16) [Bounds](https://github.com/golang/go/blob/master/src/image/image.go#L732 "View Source") ``` func (p *Gray16) Bounds() Rectangle ``` ### func (\*Gray16) [ColorModel](https://github.com/golang/go/blob/master/src/image/image.go#L730 "View Source") ``` func (p *Gray16) ColorModel() color.Model ``` ### func (\*Gray16) [Opaque](https://github.com/golang/go/blob/master/src/image/image.go#L786 "View Source") ``` func (p *Gray16) Opaque() bool ``` Opaque方法掃描整個圖像并報告圖像是否是完全不透明的。 ### func (\*Gray16) [PixOffset](https://github.com/golang/go/blob/master/src/image/image.go#L744 "View Source") ``` func (p *Gray16) PixOffset(x, y int) int ``` PixOffset方法返回像素(x, y)的數據起始位置在Pix字段的偏移量/索引。 ### func (\*Gray16) [Set](https://github.com/golang/go/blob/master/src/image/image.go#L748 "View Source") ``` func (p *Gray16) Set(x, y int, c color.Color) ``` ### func (\*Gray16) [SetGray16](https://github.com/golang/go/blob/master/src/image/image.go#L758 "View Source") ``` func (p *Gray16) SetGray16(x, y int, c color.Gray16) ``` ### func (\*Gray16) [SubImage](https://github.com/golang/go/blob/master/src/image/image.go#L769 "View Source") ``` func (p *Gray16) SubImage(r Rectangle) Image ``` SubImage方法返回代表原圖像一部分(r的范圍)的新圖像。返回值和原圖像的像素數據是共用的。 ## type [RGBA](https://github.com/golang/go/blob/master/src/image/image.go#L60 "View Source") ``` type RGBA struct { // Pix保管圖像的像素色彩信息,順序為R, G, B, A // 像素(x, y)起始位置是Pix[(y-Rect.Min.Y)*Stride + (x-Rect.Min.X)*4] Pix []uint8 // Stride是Pix中每行像素占用的字節數 Stride int // Rect是圖像的范圍 Rect Rectangle } ``` RGBA類型代表一幅內存中的圖像,其At方法返回color.RGBA類型的值。 ### func [NewRGBA](https://github.com/golang/go/blob/master/src/image/image.go#L148 "View Source") ``` func NewRGBA(r Rectangle) *RGBA ``` NewRGBA函數創建并返回一個具有指定范圍的RGBA。 ### func (\*RGBA) [At](https://github.com/golang/go/blob/master/src/image/image.go#L74 "View Source") ``` func (p *RGBA) At(x, y int) color.Color ``` ### func (\*RGBA) [Bounds](https://github.com/golang/go/blob/master/src/image/image.go#L72 "View Source") ``` func (p *RGBA) Bounds() Rectangle ``` ### func (\*RGBA) [ColorModel](https://github.com/golang/go/blob/master/src/image/image.go#L70 "View Source") ``` func (p *RGBA) ColorModel() color.Model ``` ### func (\*RGBA) [Opaque](https://github.com/golang/go/blob/master/src/image/image.go#L130 "View Source") ``` func (p *RGBA) Opaque() bool ``` Opaque方法掃描整個圖像并報告圖像是否是完全不透明的。 ### func (\*RGBA) [PixOffset](https://github.com/golang/go/blob/master/src/image/image.go#L84 "View Source") ``` func (p *RGBA) PixOffset(x, y int) int ``` PixOffset方法返回像素(x, y)的數據起始位置在Pix字段的偏移量/索引。 ### func (\*RGBA) [Set](https://github.com/golang/go/blob/master/src/image/image.go#L88 "View Source") ``` func (p *RGBA) Set(x, y int, c color.Color) ``` ### func (\*RGBA) [SetRGBA](https://github.com/golang/go/blob/master/src/image/image.go#L100 "View Source") ``` func (p *RGBA) SetRGBA(x, y int, c color.RGBA) ``` ### func (\*RGBA) [SubImage](https://github.com/golang/go/blob/master/src/image/image.go#L113 "View Source") ``` func (p *RGBA) SubImage(r Rectangle) Image ``` SubImage方法返回代表原圖像一部分(r的范圍)的新圖像。返回值和原圖像的像素數據是共用的。 ## type [RGBA64](https://github.com/golang/go/blob/master/src/image/image.go#L155 "View Source") ``` type RGBA64 struct { // Pix保管圖像的像素色彩信息,順序為R, G, B, A(每個值都是大端在前的格式) // 像素(x, y)起始位置是Pix[(y-Rect.Min.Y)*Stride + (x-Rect.Min.X)*8] Pix []uint8 // Stride是Pix中每行像素占用的字節數 Stride int // Rect是圖像的范圍 Rect Rectangle } ``` RGBA64類型代表一幅內存中的圖像,其At方法返回color.RGBA64類型的值 ### func [NewRGBA64](https://github.com/golang/go/blob/master/src/image/image.go#L256 "View Source") ``` func NewRGBA64(r Rectangle) *RGBA64 ``` NewRGBA64函數創建并返回一個具有指定范圍的RGBA64 ### func (\*RGBA64) [At](https://github.com/golang/go/blob/master/src/image/image.go#L169 "View Source") ``` func (p *RGBA64) At(x, y int) color.Color ``` ### func (\*RGBA64) [Bounds](https://github.com/golang/go/blob/master/src/image/image.go#L167 "View Source") ``` func (p *RGBA64) Bounds() Rectangle ``` ### func (\*RGBA64) [ColorModel](https://github.com/golang/go/blob/master/src/image/image.go#L165 "View Source") ``` func (p *RGBA64) ColorModel() color.Model ``` ### func (\*RGBA64) [Opaque](https://github.com/golang/go/blob/master/src/image/image.go#L238 "View Source") ``` func (p *RGBA64) Opaque() bool ``` Opaque方法掃描整個圖像并報告圖像是否是完全不透明的。 ### func (\*RGBA64) [PixOffset](https://github.com/golang/go/blob/master/src/image/image.go#L184 "View Source") ``` func (p *RGBA64) PixOffset(x, y int) int ``` PixOffset方法返回像素(x, y)的數據起始位置在Pix字段的偏移量/索引。 ### func (\*RGBA64) [Set](https://github.com/golang/go/blob/master/src/image/image.go#L188 "View Source") ``` func (p *RGBA64) Set(x, y int, c color.Color) ``` ### func (\*RGBA64) [SetRGBA64](https://github.com/golang/go/blob/master/src/image/image.go#L204 "View Source") ``` func (p *RGBA64) SetRGBA64(x, y int, c color.RGBA64) ``` ### func (\*RGBA64) [SubImage](https://github.com/golang/go/blob/master/src/image/image.go#L221 "View Source") ``` func (p *RGBA64) SubImage(r Rectangle) Image ``` SubImage方法返回代表原圖像一部分(r的范圍)的新圖像。返回值和原圖像的像素數據是共用的。 ## type [NRGBA](https://github.com/golang/go/blob/master/src/image/image.go#L263 "View Source") ``` type NRGBA struct { // Pix保管圖像的像素色彩信息,順序為R, G, B, A // 像素(x, y)起始位置是Pix[(y-Rect.Min.Y)*Stride + (x-Rect.Min.X)*4] Pix []uint8 // Stride是Pix中每行像素占用的字節數 Stride int // Rect是圖像的范圍 Rect Rectangle } ``` NRGBA類型代表一幅內存中的圖像,其At方法返回color.NRGBA類型的值。 ### func [NewNRGBA](https://github.com/golang/go/blob/master/src/image/image.go#L351 "View Source") ``` func NewNRGBA(r Rectangle) *NRGBA ``` NewNRGBA函數創建并返回一個具有指定范圍的NRGBA。 ### func (\*NRGBA) [At](https://github.com/golang/go/blob/master/src/image/image.go#L277 "View Source") ``` func (p *NRGBA) At(x, y int) color.Color ``` ### func (\*NRGBA) [Bounds](https://github.com/golang/go/blob/master/src/image/image.go#L275 "View Source") ``` func (p *NRGBA) Bounds() Rectangle ``` ### func (\*NRGBA) [ColorModel](https://github.com/golang/go/blob/master/src/image/image.go#L273 "View Source") ``` func (p *NRGBA) ColorModel() color.Model ``` ### func (\*NRGBA) [Opaque](https://github.com/golang/go/blob/master/src/image/image.go#L333 "View Source") ``` func (p *NRGBA) Opaque() bool ``` Opaque方法掃描整個圖像并報告圖像是否是完全不透明的。 ### func (\*NRGBA) [PixOffset](https://github.com/golang/go/blob/master/src/image/image.go#L287 "View Source") ``` func (p *NRGBA) PixOffset(x, y int) int ``` PixOffset方法返回像素(x, y)的數據起始位置在Pix字段的偏移量/索引。 ### func (\*NRGBA) [Set](https://github.com/golang/go/blob/master/src/image/image.go#L291 "View Source") ``` func (p *NRGBA) Set(x, y int, c color.Color) ``` ### func (\*NRGBA) [SetNRGBA](https://github.com/golang/go/blob/master/src/image/image.go#L303 "View Source") ``` func (p *NRGBA) SetNRGBA(x, y int, c color.NRGBA) ``` ### func (\*NRGBA) [SubImage](https://github.com/golang/go/blob/master/src/image/image.go#L316 "View Source") ``` func (p *NRGBA) SubImage(r Rectangle) Image ``` SubImage方法返回代表原圖像一部分(r的范圍)的新圖像。返回值和原圖像的像素數據是共用的。 ## type [NRGBA64](https://github.com/golang/go/blob/master/src/image/image.go#L358 "View Source") ``` type NRGBA64 struct { // Pix保管圖像的像素色彩信息,順序為R, G, B, A(每個值都是大端在前的格式) // 像素(x, y)起始位置是Pix[(y-Rect.Min.Y)*Stride + (x-Rect.Min.X)*8] Pix []uint8 // Stride是Pix中每行像素占用的字節數 Stride int // Rect是圖像的范圍 Rect Rectangle } ``` NRGBA64類型代表一幅內存中的圖像,其At方法返回color.NRGBA64類型的值。 ### func [NewNRGBA64](https://github.com/golang/go/blob/master/src/image/image.go#L459 "View Source") ``` func NewNRGBA64(r Rectangle) *NRGBA64 ``` NewNRGBA64函數創建并返回一個具有指定范圍的NRGBA64。 ### func (\*NRGBA64) [At](https://github.com/golang/go/blob/master/src/image/image.go#L372 "View Source") ``` func (p *NRGBA64) At(x, y int) color.Color ``` ### func (\*NRGBA64) [Bounds](https://github.com/golang/go/blob/master/src/image/image.go#L370 "View Source") ``` func (p *NRGBA64) Bounds() Rectangle ``` ### func (\*NRGBA64) [ColorModel](https://github.com/golang/go/blob/master/src/image/image.go#L368 "View Source") ``` func (p *NRGBA64) ColorModel() color.Model ``` ### func (\*NRGBA64) [Opaque](https://github.com/golang/go/blob/master/src/image/image.go#L441 "View Source") ``` func (p *NRGBA64) Opaque() bool ``` Opaque方法掃描整個圖像并報告圖像是否是完全不透明的。 ### func (\*NRGBA64) [PixOffset](https://github.com/golang/go/blob/master/src/image/image.go#L387 "View Source") ``` func (p *NRGBA64) PixOffset(x, y int) int ``` PixOffset方法返回像素(x, y)的數據起始位置在Pix字段的偏移量/索引。 ### func (\*NRGBA64) [Set](https://github.com/golang/go/blob/master/src/image/image.go#L391 "View Source") ``` func (p *NRGBA64) Set(x, y int, c color.Color) ``` ### func (\*NRGBA64) [SetNRGBA64](https://github.com/golang/go/blob/master/src/image/image.go#L407 "View Source") ``` func (p *NRGBA64) SetNRGBA64(x, y int, c color.NRGBA64) ``` ### func (\*NRGBA64) [SubImage](https://github.com/golang/go/blob/master/src/image/image.go#L424 "View Source") ``` func (p *NRGBA64) SubImage(r Rectangle) Image ``` SubImage方法返回代表原圖像一部分(r的范圍)的新圖像。返回值和原圖像的像素數據是共用的。 ## type [Paletted](https://github.com/golang/go/blob/master/src/image/image.go#L798 "View Source") ``` type Paletted struct { // Pix保存圖像的象素,內容為調色板的索引。 // 像素(x, y)的位置是Pix[(y-Rect.Min.Y)*Stride + (x-Rect.Min.X)*1] Pix []uint8 // Stride是Pix中每行像素占用的字節數 Stride int // Rect是圖像的范圍 Rect Rectangle // Palette是圖像的調色板 Palette color.Palette } ``` Paletted類型是一幅采用uint8類型索引調色板的內存中的圖像。 ### func [NewPaletted](https://github.com/golang/go/blob/master/src/image/image.go#L900 "View Source") ``` func NewPaletted(r Rectangle, p color.Palette) *Paletted ``` NewPaletted函數創建并返回一個具有指定范圍、調色板的Paletted。 ### func (\*Paletted) [At](https://github.com/golang/go/blob/master/src/image/image.go#L814 "View Source") ``` func (p *Paletted) At(x, y int) color.Color ``` ### func (\*Paletted) [Bounds](https://github.com/golang/go/blob/master/src/image/image.go#L812 "View Source") ``` func (p *Paletted) Bounds() Rectangle ``` ### func (\*Paletted) [ColorIndexAt](https://github.com/golang/go/blob/master/src/image/image.go#L839 "View Source") ``` func (p *Paletted) ColorIndexAt(x, y int) uint8 ``` ### func (\*Paletted) [ColorModel](https://github.com/golang/go/blob/master/src/image/image.go#L810 "View Source") ``` func (p *Paletted) ColorModel() color.Model ``` ### func (\*Paletted) [Opaque](https://github.com/golang/go/blob/master/src/image/image.go#L877 "View Source") ``` func (p *Paletted) Opaque() bool ``` Opaque方法掃描整個圖像并報告圖像是否是完全不透明的。 ### func (\*Paletted) [PixOffset](https://github.com/golang/go/blob/master/src/image/image.go#L827 "View Source") ``` func (p *Paletted) PixOffset(x, y int) int ``` PixOffset方法返回像素(x, y)的數據起始位置在Pix字段的偏移量/索引。 ### func (\*Paletted) [Set](https://github.com/golang/go/blob/master/src/image/image.go#L831 "View Source") ``` func (p *Paletted) Set(x, y int, c color.Color) ``` ### func (\*Paletted) [SetColorIndex](https://github.com/golang/go/blob/master/src/image/image.go#L847 "View Source") ``` func (p *Paletted) SetColorIndex(x, y int, index uint8) ``` ### func (\*Paletted) [SubImage](https://github.com/golang/go/blob/master/src/image/image.go#L857 "View Source") ``` func (p *Paletted) SubImage(r Rectangle) Image ``` SubImage方法返回代表原圖像一部分(r的范圍)的新圖像。返回值和原圖像的像素數據是共用的。 ## type [YCbCrSubsampleRatio](https://github.com/golang/go/blob/master/src/image/ycbcr.go#L12 "View Source") ``` type YCbCrSubsampleRatio int ``` YcbCrSubsampleRatio是YCbCr圖像的色度二次采樣比率。 ``` const ( YCbCrSubsampleRatio444 YCbCrSubsampleRatio = iota YCbCrSubsampleRatio422 YCbCrSubsampleRatio420 YCbCrSubsampleRatio440 ) ``` ### func (YCbCrSubsampleRatio) [String](https://github.com/golang/go/blob/master/src/image/ycbcr.go#L21 "View Source") ``` func (s YCbCrSubsampleRatio) String() string ``` ## type [YCbCr](https://github.com/golang/go/blob/master/src/image/ycbcr.go#L46 "View Source") ``` type YCbCr struct { Y, Cb, Cr []uint8 YStride int CStride int SubsampleRatio YCbCrSubsampleRatio Rect Rectangle } ``` YcbCr代表采用Y'CbCr色彩模型的一幅內存中的圖像。每個像素都對應一個Y采樣,但每個Cb/Cr采樣對應多個像素。Ystride是兩個垂直相鄰的像素之間的Y組分的索引增量。CStride是兩個映射到單獨的色度采樣的垂直相鄰的像素之間的Cb/Cr組分的索引增量。雖然不作絕對要求,但Ystride字段和len(Y)一般應為8的倍數,并且: ``` For 4:4:4, CStride == YStride/1 && len(Cb) == len(Cr) == len(Y)/1. For 4:2:2, CStride == YStride/2 && len(Cb) == len(Cr) == len(Y)/2. For 4:2:0, CStride == YStride/2 && len(Cb) == len(Cr) == len(Y)/4. For 4:4:0, CStride == YStride/1 && len(Cb) == len(Cr) == len(Y)/2. ``` ### func [NewYCbCr](https://github.com/golang/go/blob/master/src/image/ycbcr.go#L126 "View Source") ``` func NewYCbCr(r Rectangle, subsampleRatio YCbCrSubsampleRatio) *YCbCr ``` NewYCbCr函數創建并返回一個具有指定寬度、高度和二次采樣率的YcbCr。 ### func (\*YCbCr) [At](https://github.com/golang/go/blob/master/src/image/ycbcr.go#L62 "View Source") ``` func (p *YCbCr) At(x, y int) color.Color ``` ### func (\*YCbCr) [Bounds](https://github.com/golang/go/blob/master/src/image/ycbcr.go#L58 "View Source") ``` func (p *YCbCr) Bounds() Rectangle ``` ### func (\*YCbCr) [ColorModel](https://github.com/golang/go/blob/master/src/image/ycbcr.go#L54 "View Source") ``` func (p *YCbCr) ColorModel() color.Model ``` ### func (\*YCbCr) [Opaque](https://github.com/golang/go/blob/master/src/image/ycbcr.go#L121 "View Source") ``` func (p *YCbCr) Opaque() bool ``` ### func (\*YCbCr) [COffset](https://github.com/golang/go/blob/master/src/image/ycbcr.go#L83 "View Source") ``` func (p *YCbCr) COffset(x, y int) int ``` 像素(X, Y)的Cb或Cr(色度)組分的數據起始位置在Cb/Cr字段的偏移量/索引。 ### func (\*YCbCr) [YOffset](https://github.com/golang/go/blob/master/src/image/ycbcr.go#L77 "View Source") ``` func (p *YCbCr) YOffset(x, y int) int ``` 像素(X, Y)的Y(亮度)組分的數據起始位置在Y字段的偏移量/索引。 ### func (\*YCbCr) [SubImage](https://github.com/golang/go/blob/master/src/image/ycbcr.go#L98 "View Source") ``` func (p *YCbCr) SubImage(r Rectangle) Image ``` SubImage方法返回代表原圖像一部分(r的范圍)的新圖像。返回值和原圖像的像素數據是共用的。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看