Involved Source Filesformat.gogeom.go Package image implements a basic 2-D image library.
The fundamental interface is called Image. An Image contains colors, which
are described in the image/color package.
Values of the Image interface are created either by calling functions such
as NewRGBA and NewPaletted, or by calling Decode on an io.Reader containing
image data in a format such as GIF, JPEG or PNG. Decoding any particular
image format requires the prior registration of a decoder function.
Registration is typically automatic as a side effect of initializing that
format's package so that, to decode a PNG image, it suffices to have
import _ "image/png"
in a program's main package. The _ means to import a package purely for its
initialization side effects.
See "The Go image package" for more details:
https://golang.org/doc/articles/image_package.htmlnames.goycbcr.go
Package-Level Type Names (total 22, in which 20 are exported)
/* sort exporteds by: | */
Alpha is an in-memory image whose At method returns color.Alpha values. Pix holds the image's pixels, in R, G, B, A order. The pixel at
(x, y) starts at Pix[(y-Rect.Min.Y)*Stride + (x-Rect.Min.X)*4]. Rect is the image's bounds. Stride is the Pix stride (in bytes) between vertically adjacent pixels.(*Alpha) AlphaAt(x, y int) color.Alpha(*Alpha) At(x, y int) color.Color(*Alpha) Bounds() Rectangle(*Alpha) ColorModel() color.Model Opaque scans the entire image and reports whether it is fully opaque. PixOffset returns the index of the first element of Pix that corresponds to
the pixel at (x, y).(*Alpha) RGBA64At(x, y int) color.RGBA64(*Alpha) Set(x, y int, c color.Color)(*Alpha) SetAlpha(x, y int, c color.Alpha)(*Alpha) SetRGBA64(x, y int, c color.RGBA64) SubImage returns an image representing the portion of the image p visible
through r. The returned value shares pixels with the original image.
*Alpha : Image
*Alpha : RGBA64Image
func NewAlpha(r Rectangle) *Alpha
Alpha16 is an in-memory image whose At method returns color.Alpha16 values. Pix holds the image's pixels, in R, G, B, A order. The pixel at
(x, y) starts at Pix[(y-Rect.Min.Y)*Stride + (x-Rect.Min.X)*4]. Rect is the image's bounds. Stride is the Pix stride (in bytes) between vertically adjacent pixels.(*Alpha16) Alpha16At(x, y int) color.Alpha16(*Alpha16) At(x, y int) color.Color(*Alpha16) Bounds() Rectangle(*Alpha16) ColorModel() color.Model Opaque scans the entire image and reports whether it is fully opaque. PixOffset returns the index of the first element of Pix that corresponds to
the pixel at (x, y).(*Alpha16) RGBA64At(x, y int) color.RGBA64(*Alpha16) Set(x, y int, c color.Color)(*Alpha16) SetAlpha16(x, y int, c color.Alpha16)(*Alpha16) SetRGBA64(x, y int, c color.RGBA64) SubImage returns an image representing the portion of the image p visible
through r. The returned value shares pixels with the original image.
*Alpha16 : Image
*Alpha16 : RGBA64Image
func NewAlpha16(r Rectangle) *Alpha16
CMYK is an in-memory image whose At method returns color.CMYK values. Pix holds the image's pixels, in R, G, B, A order. The pixel at
(x, y) starts at Pix[(y-Rect.Min.Y)*Stride + (x-Rect.Min.X)*4]. Rect is the image's bounds. Stride is the Pix stride (in bytes) between vertically adjacent pixels.(*CMYK) At(x, y int) color.Color(*CMYK) Bounds() Rectangle(*CMYK) CMYKAt(x, y int) color.CMYK(*CMYK) ColorModel() color.Model Opaque scans the entire image and reports whether it is fully opaque. PixOffset returns the index of the first element of Pix that corresponds to
the pixel at (x, y).(*CMYK) RGBA64At(x, y int) color.RGBA64(*CMYK) Set(x, y int, c color.Color)(*CMYK) SetCMYK(x, y int, c color.CMYK)(*CMYK) SetRGBA64(x, y int, c color.RGBA64) SubImage returns an image representing the portion of the image p visible
through r. The returned value shares pixels with the original image.
*CMYK : Image
*CMYK : RGBA64Image
func NewCMYK(r Rectangle) *CMYK
Gray is an in-memory image whose At method returns color.Gray values. Pix holds the image's pixels, in R, G, B, A order. The pixel at
(x, y) starts at Pix[(y-Rect.Min.Y)*Stride + (x-Rect.Min.X)*4]. Rect is the image's bounds. Stride is the Pix stride (in bytes) between vertically adjacent pixels.(*Gray) At(x, y int) color.Color(*Gray) Bounds() Rectangle(*Gray) ColorModel() color.Model(*Gray) GrayAt(x, y int) color.Gray Opaque scans the entire image and reports whether it is fully opaque. PixOffset returns the index of the first element of Pix that corresponds to
the pixel at (x, y).(*Gray) RGBA64At(x, y int) color.RGBA64(*Gray) Set(x, y int, c color.Color)(*Gray) SetGray(x, y int, c color.Gray)(*Gray) SetRGBA64(x, y int, c color.RGBA64) SubImage returns an image representing the portion of the image p visible
through r. The returned value shares pixels with the original image.
*Gray : Image
*Gray : RGBA64Image
func NewGray(r Rectangle) *Gray
Gray16 is an in-memory image whose At method returns color.Gray16 values. Pix holds the image's pixels, in R, G, B, A order. The pixel at
(x, y) starts at Pix[(y-Rect.Min.Y)*Stride + (x-Rect.Min.X)*4]. Rect is the image's bounds. Stride is the Pix stride (in bytes) between vertically adjacent pixels.(*Gray16) At(x, y int) color.Color(*Gray16) Bounds() Rectangle(*Gray16) ColorModel() color.Model(*Gray16) Gray16At(x, y int) color.Gray16 Opaque scans the entire image and reports whether it is fully opaque. PixOffset returns the index of the first element of Pix that corresponds to
the pixel at (x, y).(*Gray16) RGBA64At(x, y int) color.RGBA64(*Gray16) Set(x, y int, c color.Color)(*Gray16) SetGray16(x, y int, c color.Gray16)(*Gray16) SetRGBA64(x, y int, c color.RGBA64) SubImage returns an image representing the portion of the image p visible
through r. The returned value shares pixels with the original image.
*Gray16 : Image
*Gray16 : RGBA64Image
func NewGray16(r Rectangle) *Gray16
NRGBA is an in-memory image whose At method returns color.NRGBA values. Pix holds the image's pixels, in R, G, B, A order. The pixel at
(x, y) starts at Pix[(y-Rect.Min.Y)*Stride + (x-Rect.Min.X)*4]. Rect is the image's bounds. Stride is the Pix stride (in bytes) between vertically adjacent pixels.(*NRGBA) At(x, y int) color.Color(*NRGBA) Bounds() Rectangle(*NRGBA) ColorModel() color.Model(*NRGBA) NRGBAAt(x, y int) color.NRGBA Opaque scans the entire image and reports whether it is fully opaque. PixOffset returns the index of the first element of Pix that corresponds to
the pixel at (x, y).(*NRGBA) RGBA64At(x, y int) color.RGBA64(*NRGBA) Set(x, y int, c color.Color)(*NRGBA) SetNRGBA(x, y int, c color.NRGBA)(*NRGBA) SetRGBA64(x, y int, c color.RGBA64) SubImage returns an image representing the portion of the image p visible
through r. The returned value shares pixels with the original image.
*NRGBA : Image
*NRGBA : RGBA64Image
func NewNRGBA(r Rectangle) *NRGBA
NRGBA64 is an in-memory image whose At method returns color.NRGBA64 values. Pix holds the image's pixels, in R, G, B, A order. The pixel at
(x, y) starts at Pix[(y-Rect.Min.Y)*Stride + (x-Rect.Min.X)*4]. Rect is the image's bounds. Stride is the Pix stride (in bytes) between vertically adjacent pixels.(*NRGBA64) At(x, y int) color.Color(*NRGBA64) Bounds() Rectangle(*NRGBA64) ColorModel() color.Model(*NRGBA64) NRGBA64At(x, y int) color.NRGBA64 Opaque scans the entire image and reports whether it is fully opaque. PixOffset returns the index of the first element of Pix that corresponds to
the pixel at (x, y).(*NRGBA64) RGBA64At(x, y int) color.RGBA64(*NRGBA64) Set(x, y int, c color.Color)(*NRGBA64) SetNRGBA64(x, y int, c color.NRGBA64)(*NRGBA64) SetRGBA64(x, y int, c color.RGBA64) SubImage returns an image representing the portion of the image p visible
through r. The returned value shares pixels with the original image.
*NRGBA64 : Image
*NRGBA64 : RGBA64Image
func NewNRGBA64(r Rectangle) *NRGBA64
Paletted is an in-memory image of uint8 indices into a given palette. Palette is the image's palette. Pix holds the image's pixels, as palette indices. The pixel at
(x, y) starts at Pix[(y-Rect.Min.Y)*Stride + (x-Rect.Min.X)*1]. Rect is the image's bounds. Stride is the Pix stride (in bytes) between vertically adjacent pixels.(*Paletted) At(x, y int) color.Color(*Paletted) Bounds() Rectangle(*Paletted) ColorIndexAt(x, y int) uint8(*Paletted) ColorModel() color.Model Opaque scans the entire image and reports whether it is fully opaque. PixOffset returns the index of the first element of Pix that corresponds to
the pixel at (x, y).(*Paletted) RGBA64At(x, y int) color.RGBA64(*Paletted) Set(x, y int, c color.Color)(*Paletted) SetColorIndex(x, y int, index uint8)(*Paletted) SetRGBA64(x, y int, c color.RGBA64) SubImage returns an image representing the portion of the image p visible
through r. The returned value shares pixels with the original image.
*Paletted : Image
*Paletted : PalettedImage
*Paletted : RGBA64Image
func NewPaletted(r Rectangle, p color.Palette) *Paletted
PalettedImage is an image whose colors may come from a limited palette.
If m is a PalettedImage and m.ColorModel() returns a color.Palette p,
then m.At(x, y) should be equivalent to p[m.ColorIndexAt(x, y)]. If m's
color model is not a color.Palette, then ColorIndexAt's behavior is
undefined. At returns the color of the pixel at (x, y).
At(Bounds().Min.X, Bounds().Min.Y) returns the upper-left pixel of the grid.
At(Bounds().Max.X-1, Bounds().Max.Y-1) returns the lower-right one. Bounds returns the domain for which At can return non-zero color.
The bounds do not necessarily contain the point (0, 0). ColorIndexAt returns the palette index of the pixel at (x, y). ColorModel returns the Image's color model.
*Paletted
PalettedImage : Image
A Point is an X, Y coordinate pair. The axes increase right and down.XintYint Add returns the vector p+q. Div returns the vector p/k. Eq reports whether p and q are equal. In reports whether p is in r. Mod returns the point q in r such that p.X-q.X is a multiple of r's width
and p.Y-q.Y is a multiple of r's height. Mul returns the vector p*k. String returns a string representation of p like "(3,4)". Sub returns the vector p-q.
Point : fmt.Stringer
Point : context.stringer
Point : runtime.stringer
func Pt(X, Y int) Point
func Point.Add(q Point) Point
func Point.Div(k int) Point
func Point.Mod(r Rectangle) Point
func Point.Mul(k int) Point
func Point.Sub(q Point) Point
func Rectangle.Size() Point
func Point.Add(q Point) Point
func Point.Eq(q Point) bool
func Point.Sub(q Point) Point
func Rectangle.Add(p Point) Rectangle
func Rectangle.Sub(p Point) Rectangle
var ZP
A Rectangle contains the points with Min.X <= X < Max.X, Min.Y <= Y < Max.Y.
It is well-formed if Min.X <= Max.X and likewise for Y. Points are always
well-formed. A rectangle's methods always return well-formed outputs for
well-formed inputs.
A Rectangle is also an Image whose bounds are the rectangle itself. At
returns color.Opaque for points in the rectangle and color.Transparent
otherwise.MaxPointMinPoint Add returns the rectangle r translated by p. At implements the Image interface. Bounds implements the Image interface. Canon returns the canonical version of r. The returned rectangle has minimum
and maximum coordinates swapped if necessary so that it is well-formed. ColorModel implements the Image interface. Dx returns r's width. Dy returns r's height. Empty reports whether the rectangle contains no points. Eq reports whether r and s contain the same set of points. All empty
rectangles are considered equal. In reports whether every point in r is in s. Inset returns the rectangle r inset by n, which may be negative. If either
of r's dimensions is less than 2*n then an empty rectangle near the center
of r will be returned. Intersect returns the largest rectangle contained by both r and s. If the
two rectangles do not overlap then the zero rectangle will be returned. Overlaps reports whether r and s have a non-empty intersection. RGBA64At implements the RGBA64Image interface. Size returns r's width and height. String returns a string representation of r like "(3,4)-(6,5)". Sub returns the rectangle r translated by -p. Union returns the smallest rectangle that contains both r and s.
Rectangle : Image
Rectangle : RGBA64Image
Rectangle : fmt.Stringer
Rectangle : context.stringer
Rectangle : runtime.stringer
func Rect(x0, y0, x1, y1 int) Rectangle
func (*Alpha).Bounds() Rectangle
func (*Alpha16).Bounds() Rectangle
func (*CMYK).Bounds() Rectangle
func (*Gray).Bounds() Rectangle
func (*Gray16).Bounds() Rectangle
func Image.Bounds() Rectangle
func (*NRGBA).Bounds() Rectangle
func (*NRGBA64).Bounds() Rectangle
func (*Paletted).Bounds() Rectangle
func PalettedImage.Bounds() Rectangle
func Rectangle.Add(p Point) Rectangle
func Rectangle.Bounds() Rectangle
func Rectangle.Canon() Rectangle
func Rectangle.Inset(n int) Rectangle
func Rectangle.Intersect(s Rectangle) Rectangle
func Rectangle.Sub(p Point) Rectangle
func Rectangle.Union(s Rectangle) Rectangle
func (*RGBA).Bounds() Rectangle
func (*RGBA64).Bounds() Rectangle
func RGBA64Image.Bounds() Rectangle
func (*Uniform).Bounds() Rectangle
func (*YCbCr).Bounds() Rectangle
func NewAlpha(r Rectangle) *Alpha
func NewAlpha16(r Rectangle) *Alpha16
func NewCMYK(r Rectangle) *CMYK
func NewGray(r Rectangle) *Gray
func NewGray16(r Rectangle) *Gray16
func NewNRGBA(r Rectangle) *NRGBA
func NewNRGBA64(r Rectangle) *NRGBA64
func NewNYCbCrA(r Rectangle, subsampleRatio YCbCrSubsampleRatio) *NYCbCrA
func NewPaletted(r Rectangle, p color.Palette) *Paletted
func NewRGBA(r Rectangle) *RGBA
func NewRGBA64(r Rectangle) *RGBA64
func NewYCbCr(r Rectangle, subsampleRatio YCbCrSubsampleRatio) *YCbCr
func (*Alpha).SubImage(r Rectangle) Image
func (*Alpha16).SubImage(r Rectangle) Image
func (*CMYK).SubImage(r Rectangle) Image
func (*Gray).SubImage(r Rectangle) Image
func (*Gray16).SubImage(r Rectangle) Image
func (*NRGBA).SubImage(r Rectangle) Image
func (*NRGBA64).SubImage(r Rectangle) Image
func (*NYCbCrA).SubImage(r Rectangle) Image
func (*Paletted).SubImage(r Rectangle) Image
func Point.In(r Rectangle) bool
func Point.Mod(r Rectangle) Point
func Rectangle.Eq(s Rectangle) bool
func Rectangle.In(s Rectangle) bool
func Rectangle.Intersect(s Rectangle) Rectangle
func Rectangle.Overlaps(s Rectangle) bool
func Rectangle.Union(s Rectangle) Rectangle
func (*RGBA).SubImage(r Rectangle) Image
func (*RGBA64).SubImage(r Rectangle) Image
func (*YCbCr).SubImage(r Rectangle) Image
func pixelBufferLength(bytesPerPixel int, r Rectangle, imageTypeName string) int
func yCbCrSize(r Rectangle, subsampleRatio YCbCrSubsampleRatio) (w, h, cw, ch int)
var ZR
RGBA is an in-memory image whose At method returns color.RGBA values. Pix holds the image's pixels, in R, G, B, A order. The pixel at
(x, y) starts at Pix[(y-Rect.Min.Y)*Stride + (x-Rect.Min.X)*4]. Rect is the image's bounds. Stride is the Pix stride (in bytes) between vertically adjacent pixels.(*RGBA) At(x, y int) color.Color(*RGBA) Bounds() Rectangle(*RGBA) ColorModel() color.Model Opaque scans the entire image and reports whether it is fully opaque. PixOffset returns the index of the first element of Pix that corresponds to
the pixel at (x, y).(*RGBA) RGBA64At(x, y int) color.RGBA64(*RGBA) RGBAAt(x, y int) color.RGBA(*RGBA) Set(x, y int, c color.Color)(*RGBA) SetRGBA(x, y int, c color.RGBA)(*RGBA) SetRGBA64(x, y int, c color.RGBA64) SubImage returns an image representing the portion of the image p visible
through r. The returned value shares pixels with the original image.
*RGBA : Image
*RGBA : RGBA64Image
func NewRGBA(r Rectangle) *RGBA
RGBA64 is an in-memory image whose At method returns color.RGBA64 values. Pix holds the image's pixels, in R, G, B, A order. The pixel at
(x, y) starts at Pix[(y-Rect.Min.Y)*Stride + (x-Rect.Min.X)*4]. Rect is the image's bounds. Stride is the Pix stride (in bytes) between vertically adjacent pixels.(*RGBA64) At(x, y int) color.Color(*RGBA64) Bounds() Rectangle(*RGBA64) ColorModel() color.Model Opaque scans the entire image and reports whether it is fully opaque. PixOffset returns the index of the first element of Pix that corresponds to
the pixel at (x, y).(*RGBA64) RGBA64At(x, y int) color.RGBA64(*RGBA64) Set(x, y int, c color.Color)(*RGBA64) SetRGBA64(x, y int, c color.RGBA64) SubImage returns an image representing the portion of the image p visible
through r. The returned value shares pixels with the original image.
*RGBA64 : Image
*RGBA64 : RGBA64Image
func NewRGBA64(r Rectangle) *RGBA64
RGBA64Image is an Image whose pixels can be converted directly to a
color.RGBA64. At returns the color of the pixel at (x, y).
At(Bounds().Min.X, Bounds().Min.Y) returns the upper-left pixel of the grid.
At(Bounds().Max.X-1, Bounds().Max.Y-1) returns the lower-right one. Bounds returns the domain for which At can return non-zero color.
The bounds do not necessarily contain the point (0, 0). ColorModel returns the Image's color model. RGBA64At returns the RGBA64 color of the pixel at (x, y). It is
equivalent to calling At(x, y).RGBA() and converting the resulting
32-bit return values to a color.RGBA64, but it can avoid allocations
from converting concrete color types to the color.Color interface type.
*Alpha
*Alpha16
*CMYK
*Gray
*Gray16
*NRGBA
*NRGBA64
*NYCbCrA
*PalettedRectangle
*RGBA
*RGBA64
*Uniform
*YCbCr
RGBA64Image : Image
YCbCr is an in-memory image of Y'CbCr colors. There is one Y sample per
pixel, but each Cb and Cr sample can span one or more pixels.
YStride is the Y slice index delta between vertically adjacent pixels.
CStride is the Cb and Cr slice index delta between vertically adjacent pixels
that map to separate chroma samples.
It is not an absolute requirement, but YStride and len(Y) are typically
multiples of 8, and:
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.
For 4:1:1, CStride == YStride/4 && len(Cb) == len(Cr) == len(Y)/4.
For 4:1:0, CStride == YStride/4 && len(Cb) == len(Cr) == len(Y)/8.CStrideintCb[]uint8Cr[]uint8RectRectangleSubsampleRatioYCbCrSubsampleRatioY[]uint8YStrideint(*YCbCr) At(x, y int) color.Color(*YCbCr) Bounds() Rectangle COffset returns the index of the first element of Cb or Cr that corresponds
to the pixel at (x, y).(*YCbCr) ColorModel() color.Model(*YCbCr) Opaque() bool(*YCbCr) RGBA64At(x, y int) color.RGBA64 SubImage returns an image representing the portion of the image p visible
through r. The returned value shares pixels with the original image.(*YCbCr) YCbCrAt(x, y int) color.YCbCr YOffset returns the index of the first element of Y that corresponds to
the pixel at (x, y).
*YCbCr : Image
*YCbCr : RGBA64Image
func NewYCbCr(r Rectangle, subsampleRatio YCbCrSubsampleRatio) *YCbCr
Package-Level Functions (total 25, in which 18 are exported)
Decode decodes an image that has been encoded in a registered format.
The string returned is the format name used during format registration.
Format registration is typically done by an init function in the codec-
specific package.
DecodeConfig decodes the color model and dimensions of an image that has
been encoded in a registered format. The string returned is the format name
used during format registration. Format registration is typically done by
an init function in the codec-specific package.
NewAlpha returns a new Alpha image with the given bounds.
NewAlpha16 returns a new Alpha16 image with the given bounds.
NewCMYK returns a new CMYK image with the given bounds.
NewGray returns a new Gray image with the given bounds.
NewGray16 returns a new Gray16 image with the given bounds.
NewNRGBA returns a new NRGBA image with the given bounds.
NewNRGBA64 returns a new NRGBA64 image with the given bounds.
NewNYCbCrA returns a new NYCbCrA image with the given bounds and subsample
ratio.
NewPaletted returns a new Paletted image with the given width, height and
palette.
NewRGBA returns a new RGBA image with the given bounds.
NewRGBA64 returns a new RGBA64 image with the given bounds.
NewUniform returns a new Uniform image of the given color.
NewYCbCr returns a new YCbCr image with the given bounds and subsample
ratio.
Pt is shorthand for Point{X, Y}.
Rect is shorthand for Rectangle{Pt(x0, y0), Pt(x1, y1)}. The returned
rectangle has minimum and maximum coordinates swapped if necessary so that
it is well-formed.
RegisterFormat registers an image format for use by Decode.
Name is the name of the format, like "jpeg" or "png".
Magic is the magic prefix that identifies the format's encoding. The magic
string can contain "?" wildcards that each match any one byte.
Decode is the function that decodes the encoded image.
DecodeConfig is the function that decodes just its configuration.
add2NonNeg returns (x + y), unless at least one argument is negative or if
the computation overflows the int type, in which case it returns -1.
asReader converts an io.Reader to a reader.
match reports whether magic matches b. Magic may contain "?" wildcards.
mul3NonNeg returns (x * y * z), unless at least one argument is negative or
if the computation overflows the int type, in which case it returns -1.
pixelBufferLength returns the length of the []uint8 typed Pix slice field
for the NewXxx functions. Conceptually, this is just (bpp * width * height),
but this function panics if at least one of those is negative or if the
computation would overflow the int type.
This panics instead of returning an error because of backwards
compatibility. The NewXxx functions do not return an error.
The pages are generated with Goldsv0.6.7. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds.