Documentation ¶
Overview ¶
Package image implements a basic 2-D image library.
Index ¶
- Variables
- func RegisterFormat(name, magic string, decode func(io.Reader) (Image, os.Error), ...)
- type Alpha
- type Alpha16
- type Alpha16Color
- type AlphaColor
- type Color
- type ColorImage
- type ColorModel
- type ColorModelFunc
- type Config
- type Gray
- type Gray16
- type Gray16Color
- type GrayColor
- type Image
- type NRGBA
- type NRGBA64
- type NRGBA64Color
- type NRGBAColor
- type Paletted
- func (p *Paletted) At(x, y int) Color
- func (p *Paletted) Bounds() Rectangle
- func (p *Paletted) ColorIndexAt(x, y int) uint8
- func (p *Paletted) ColorModel() ColorModel
- func (p *Paletted) Opaque() bool
- func (p *Paletted) SetColorIndex(x, y int, index uint8)
- func (p *Paletted) SubImage(r Rectangle) Image
- type PalettedColorModel
- type Point
- type RGBA
- type RGBA64
- type RGBA64Color
- type RGBAColor
- type Rectangle
- func (r Rectangle) Add(p Point) Rectangle
- func (r Rectangle) Canon() Rectangle
- func (r Rectangle) Dx() int
- func (r Rectangle) Dy() int
- func (r Rectangle) Empty() bool
- func (r Rectangle) Eq(s Rectangle) bool
- func (r Rectangle) In(s Rectangle) bool
- func (r Rectangle) Inset(n int) Rectangle
- func (r Rectangle) Intersect(s Rectangle) Rectangle
- func (r Rectangle) Overlaps(s Rectangle) bool
- func (r Rectangle) Size() Point
- func (r Rectangle) String() string
- func (r Rectangle) Sub(p Point) Rectangle
- func (r Rectangle) Union(s Rectangle) Rectangle
- type Tiled
Constants ¶
This section is empty.
Variables ¶
var ( // Black is an opaque black ColorImage. Black = NewColorImage(Gray16Color{0}) // White is an opaque white ColorImage. White = NewColorImage(Gray16Color{0xffff}) // Transparent is a fully transparent ColorImage. Transparent = NewColorImage(Alpha16Color{0}) // Opaque is a fully opaque ColorImage. Opaque = NewColorImage(Alpha16Color{0xffff}) )
var UnknownFormatErr = os.NewError("image: unknown format")
An UnknownFormatErr indicates that decoding encountered an unknown format.
Functions ¶
func RegisterFormat ¶
func RegisterFormat(name, magic string, decode func(io.Reader) (Image, os.Error), decodeConfig func(io.Reader) (Config, os.Error))
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.
Types ¶
type Alpha ¶
type Alpha struct { // Pix holds the image's pixels. The pixel at (x, y) is Pix[y*Stride+x]. Pix []AlphaColor Stride int // Rect is the image's bounds. Rect Rectangle }
An Alpha is an in-memory image of AlphaColor values.
func (*Alpha) ColorModel ¶
func (p *Alpha) ColorModel() ColorModel
func (*Alpha) SetAlpha ¶
func (p *Alpha) SetAlpha(x, y int, c AlphaColor)
type Alpha16 ¶
type Alpha16 struct { // Pix holds the image's pixels. The pixel at (x, y) is Pix[y*Stride+x]. Pix []Alpha16Color Stride int // Rect is the image's bounds. Rect Rectangle }
An Alpha16 is an in-memory image of Alpha16Color values.
func NewAlpha16 ¶
NewAlpha16 returns a new Alpha16 with the given width and height.
func (*Alpha16) ColorModel ¶
func (p *Alpha16) ColorModel() ColorModel
func (*Alpha16) Opaque ¶
Opaque scans the entire image and returns whether or not it is fully opaque.
func (*Alpha16) SetAlpha16 ¶
func (p *Alpha16) SetAlpha16(x, y int, c Alpha16Color)
type Alpha16Color ¶
type Alpha16Color struct {
A uint16
}
An Alpha16Color represents a 16-bit alpha.
func (Alpha16Color) RGBA ¶
func (c Alpha16Color) RGBA() (r, g, b, a uint32)
type AlphaColor ¶
type AlphaColor struct {
A uint8
}
An AlphaColor represents an 8-bit alpha.
func (AlphaColor) RGBA ¶
func (c AlphaColor) RGBA() (r, g, b, a uint32)
type Color ¶
type Color interface {
RGBA() (r, g, b, a uint32)
}
All Colors can convert themselves, with a possible loss of precision, to 64-bit alpha-premultiplied RGBA. Each channel value ranges within [0, 0xFFFF].
type ColorImage ¶
type ColorImage struct {
C Color
}
A ColorImage is an infinite-sized Image of uniform Color. It implements both the Color and Image interfaces.
func NewColorImage ¶
func NewColorImage(c Color) *ColorImage
func (*ColorImage) At ¶
func (c *ColorImage) At(x, y int) Color
func (*ColorImage) Bounds ¶
func (c *ColorImage) Bounds() Rectangle
func (*ColorImage) ColorModel ¶
func (c *ColorImage) ColorModel() ColorModel
func (*ColorImage) Opaque ¶
func (c *ColorImage) Opaque() bool
Opaque scans the entire image and returns whether or not it is fully opaque.
func (*ColorImage) RGBA ¶
func (c *ColorImage) RGBA() (r, g, b, a uint32)
type ColorModel ¶
A ColorModel can convert foreign Colors, with a possible loss of precision, to a Color from its own color model.
var Alpha16ColorModel ColorModel = ColorModelFunc(toAlpha16Color)
The ColorModel associated with Alpha16Color.
var AlphaColorModel ColorModel = ColorModelFunc(toAlphaColor)
The ColorModel associated with AlphaColor.
var Gray16ColorModel ColorModel = ColorModelFunc(toGray16Color)
The ColorModel associated with Gray16Color.
var GrayColorModel ColorModel = ColorModelFunc(toGrayColor)
The ColorModel associated with GrayColor.
var NRGBA64ColorModel ColorModel = ColorModelFunc(toNRGBA64Color)
The ColorModel associated with NRGBA64Color.
var NRGBAColorModel ColorModel = ColorModelFunc(toNRGBAColor)
The ColorModel associated with NRGBAColor.
var RGBA64ColorModel ColorModel = ColorModelFunc(toRGBA64Color)
The ColorModel associated with RGBA64Color.
var RGBAColorModel ColorModel = ColorModelFunc(toRGBAColor)
The ColorModel associated with RGBAColor.
type ColorModelFunc ¶
The ColorModelFunc type is an adapter to allow the use of an ordinary color conversion function as a ColorModel. If f is such a function, ColorModelFunc(f) is a ColorModel object that invokes f to implement the conversion.
func (ColorModelFunc) Convert ¶
func (f ColorModelFunc) Convert(c Color) Color
type Config ¶
type Config struct { ColorModel ColorModel Width, Height int }
A Config consists of an image's color model and dimensions.
func DecodeConfig ¶
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 the init method of the codec-specific package.
type Gray ¶
type Gray struct { // Pix holds the image's pixels. The pixel at (x, y) is Pix[y*Stride+x]. Pix []GrayColor Stride int // Rect is the image's bounds. Rect Rectangle }
A Gray is an in-memory image of GrayColor values.
func (*Gray) ColorModel ¶
func (p *Gray) ColorModel() ColorModel
type Gray16 ¶
type Gray16 struct { // Pix holds the image's pixels. The pixel at (x, y) is Pix[y*Stride+x]. Pix []Gray16Color Stride int // Rect is the image's bounds. Rect Rectangle }
A Gray16 is an in-memory image of Gray16Color values.
func (*Gray16) ColorModel ¶
func (p *Gray16) ColorModel() ColorModel
func (*Gray16) Opaque ¶
Opaque scans the entire image and returns whether or not it is fully opaque.
func (*Gray16) SetGray16 ¶
func (p *Gray16) SetGray16(x, y int, c Gray16Color)
type Gray16Color ¶
type Gray16Color struct {
Y uint16
}
A Gray16Color represents a 16-bit grayscale color.
func (Gray16Color) RGBA ¶
func (c Gray16Color) RGBA() (r, g, b, a uint32)
type Image ¶
type Image interface { // ColorModel returns the Image's ColorModel. ColorModel() ColorModel // Bounds returns the domain for which At can return non-zero color. // The bounds do not necessarily contain the point (0, 0). Bounds() Rectangle // 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. At(x, y int) Color }
An Image is a finite rectangular grid of Colors drawn from a ColorModel.
type NRGBA ¶
type NRGBA struct { // Pix holds the image's pixels. The pixel at (x, y) is Pix[y*Stride+x]. Pix []NRGBAColor Stride int // Rect is the image's bounds. Rect Rectangle }
An NRGBA is an in-memory image of NRGBAColor values.
func (*NRGBA) ColorModel ¶
func (p *NRGBA) ColorModel() ColorModel
func (*NRGBA) SetNRGBA ¶
func (p *NRGBA) SetNRGBA(x, y int, c NRGBAColor)
type NRGBA64 ¶
type NRGBA64 struct { // Pix holds the image's pixels. The pixel at (x, y) is Pix[y*Stride+x]. Pix []NRGBA64Color Stride int // Rect is the image's bounds. Rect Rectangle }
An NRGBA64 is an in-memory image of NRGBA64Color values.
func NewNRGBA64 ¶
NewNRGBA64 returns a new NRGBA64 with the given width and height.
func (*NRGBA64) ColorModel ¶
func (p *NRGBA64) ColorModel() ColorModel
func (*NRGBA64) Opaque ¶
Opaque scans the entire image and returns whether or not it is fully opaque.
func (*NRGBA64) SetNRGBA64 ¶
func (p *NRGBA64) SetNRGBA64(x, y int, c NRGBA64Color)
type NRGBA64Color ¶
type NRGBA64Color struct {
R, G, B, A uint16
}
An NRGBA64Color represents a non-alpha-premultiplied 64-bit color, having 16 bits for each of red, green, blue and alpha.
func (NRGBA64Color) RGBA ¶
func (c NRGBA64Color) RGBA() (r, g, b, a uint32)
type NRGBAColor ¶
type NRGBAColor struct {
R, G, B, A uint8
}
An NRGBAColor represents a non-alpha-premultiplied 32-bit color.
func (NRGBAColor) RGBA ¶
func (c NRGBAColor) RGBA() (r, g, b, a uint32)
type Paletted ¶
type Paletted struct { // Pix holds the image's pixels. The pixel at (x, y) is Pix[y*Stride+x]. Pix []uint8 Stride int // Rect is the image's bounds. Rect Rectangle // Palette is the image's palette. Palette PalettedColorModel }
A Paletted is an in-memory image backed by a 2-D slice of uint8 values and a PalettedColorModel.
func NewPaletted ¶
func NewPaletted(w, h int, m PalettedColorModel) *Paletted
NewPaletted returns a new Paletted with the given width, height and palette.
func (*Paletted) ColorIndexAt ¶
func (*Paletted) ColorModel ¶
func (p *Paletted) ColorModel() ColorModel
func (*Paletted) Opaque ¶
Opaque scans the entire image and returns whether or not it is fully opaque.
func (*Paletted) SetColorIndex ¶
type PalettedColorModel ¶
type PalettedColorModel []Color
A PalettedColorModel represents a fixed palette of colors.
func (PalettedColorModel) Convert ¶
func (p PalettedColorModel) Convert(c Color) Color
Convert returns the palette color closest to c in Euclidean R,G,B space.
type Point ¶
type Point struct {
X, Y int
}
A Point is an X, Y coordinate pair. The axes increase right and down.
var ZP Point
ZP is the zero Point.
func (Point) Mod ¶
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.
type RGBA ¶
type RGBA struct { // Pix holds the image's pixels. The pixel at (x, y) is Pix[y*Stride+x]. Pix []RGBAColor Stride int // Rect is the image's bounds. Rect Rectangle }
An RGBA is an in-memory image of RGBAColor values.
func (*RGBA) ColorModel ¶
func (p *RGBA) ColorModel() ColorModel
type RGBA64 ¶
type RGBA64 struct { // Pix holds the image's pixels. The pixel at (x, y) is Pix[y*Stride+x]. Pix []RGBA64Color Stride int // Rect is the image's bounds. Rect Rectangle }
An RGBA64 is an in-memory image of RGBA64Color values.
func (*RGBA64) ColorModel ¶
func (p *RGBA64) ColorModel() ColorModel
func (*RGBA64) Opaque ¶
Opaque scans the entire image and returns whether or not it is fully opaque.
func (*RGBA64) SetRGBA64 ¶
func (p *RGBA64) SetRGBA64(x, y int, c RGBA64Color)
type RGBA64Color ¶
type RGBA64Color struct {
R, G, B, A uint16
}
An RGBA64Color represents a 64-bit alpha-premultiplied color, having 16 bits for each of red, green, blue and alpha.
func (RGBA64Color) RGBA ¶
func (c RGBA64Color) RGBA() (r, g, b, a uint32)
type RGBAColor ¶
type RGBAColor struct {
R, G, B, A uint8
}
An RGBAColor represents a traditional 32-bit alpha-premultiplied color, having 8 bits for each of red, green, blue and alpha.
type Rectangle ¶
type Rectangle struct {
Min, Max Point
}
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.
var ZR Rectangle
ZR is the zero Rectangle.
func (Rectangle) Canon ¶
Canon returns the canonical version of r. The returned rectangle has minimum and maximum coordinates swapped if necessary so that it is well-formed.
func (Rectangle) Inset ¶
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.
func (Rectangle) Intersect ¶
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.
type Tiled ¶
A Tiled is an infinite-sized Image that repeats another Image in both directions. Tiled{i, p}.At(x, y) will equal i.At(x+p.X, y+p.Y) for all points {x+p.X, y+p.Y} within i's Bounds.
func (*Tiled) ColorModel ¶
func (t *Tiled) ColorModel() ColorModel
Directories ¶
Path | Synopsis |
---|---|
Package bmp implements a BMP image decoder.
|
Package bmp implements a BMP image decoder. |
Package draw provides image composition functions in the style of the Plan 9 graphics library (see http://plan9.bell-labs.com/magic/man2html/2/draw) and the X Render extension.
|
Package draw provides image composition functions in the style of the Plan 9 graphics library (see http://plan9.bell-labs.com/magic/man2html/2/draw) and the X Render extension. |
Package gif implements a GIF image decoder.
|
Package gif implements a GIF image decoder. |
Package jpeg implements a JPEG image decoder and encoder.
|
Package jpeg implements a JPEG image decoder and encoder. |
Package png implements a PNG image decoder and encoder.
|
Package png implements a PNG image decoder and encoder. |
Package tiff implements a TIFF image decoder.
|
Package tiff implements a TIFF image decoder. |
Package ycbcr provides images from the Y'CbCr color model.
|
Package ycbcr provides images from the Y'CbCr color model. |