image

package
v0.0.0-...-90c9d3a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 21, 2010 License: BSD-3-Clause, GooglePatentClause Imports: 0 Imported by: 0

Documentation

Overview

The image package implements a basic 2-D image library.

Index

Constants

This section is empty.

Variables

View Source
var (
	Aqua    = ColorImage{RGBAColor{0x00, 0xff, 0xff, 0xff}}
	Black   = ColorImage{RGBAColor{0x00, 0x00, 0x00, 0xff}}
	Blue    = ColorImage{RGBAColor{0x00, 0x00, 0xff, 0xff}}
	Fuchsia = ColorImage{RGBAColor{0xff, 0x00, 0xff, 0xff}}
	Gray    = ColorImage{RGBAColor{0x80, 0x80, 0x80, 0xff}}
	Green   = ColorImage{RGBAColor{0x00, 0x80, 0x00, 0xff}}
	Lime    = ColorImage{RGBAColor{0x00, 0xff, 0x00, 0xff}}
	Maroon  = ColorImage{RGBAColor{0x80, 0x00, 0x00, 0xff}}
	Navy    = ColorImage{RGBAColor{0x00, 0x00, 0x80, 0xff}}
	Olive   = ColorImage{RGBAColor{0x80, 0x80, 0x00, 0xff}}
	Red     = ColorImage{RGBAColor{0xff, 0x00, 0x00, 0xff}}
	Purple  = ColorImage{RGBAColor{0x80, 0x00, 0x80, 0xff}}
	Silver  = ColorImage{RGBAColor{0xc0, 0xc0, 0xc0, 0xff}}
	Teal    = ColorImage{RGBAColor{0x00, 0x80, 0x80, 0xff}}
	White   = ColorImage{RGBAColor{0xff, 0xff, 0xff, 0xff}}
	Yellow  = ColorImage{RGBAColor{0xff, 0xff, 0x00, 0xff}}

	// These synonyms are not in HTML 4.01.
	Cyan    = Aqua
	Magenta = Fuchsia
)

Colors from the HTML 4.01 specification: http://www.w3.org/TR/REC-html40/types.html#h-6.5 These names do not necessarily match those from other lists, such as the X11 color names.

Functions

This section is empty.

Types

type Alpha

type Alpha struct {
	// The Pixel field's indices are y first, then x, so that At(x, y) == Pixel[y][x].
	Pixel [][]AlphaColor
}

An Alpha is an in-memory image backed by a 2-D slice of AlphaColor values.

func NewAlpha

func NewAlpha(w, h int) *Alpha

NewAlpha returns a new Alpha with the given width and height.

func (*Alpha) At

func (p *Alpha) At(x, y int) Color

func (*Alpha) ColorModel

func (p *Alpha) ColorModel() ColorModel

func (*Alpha) Height

func (p *Alpha) Height() int

func (*Alpha) Set

func (p *Alpha) Set(x, y int, c Color)

func (*Alpha) Width

func (p *Alpha) Width() int

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 128-bit alpha-premultiplied RGBA.

type ColorImage

type ColorImage struct {
	C Color
}

A ColorImage is a practically infinite-sized Image of uniform Color. It implements both the Color and Image interfaces.

func (ColorImage) At

func (c ColorImage) At(x, y int) Color

func (ColorImage) ColorModel

func (c ColorImage) ColorModel() ColorModel

func (ColorImage) Height

func (c ColorImage) Height() int

func (ColorImage) RGBA

func (c ColorImage) RGBA() (r, g, b, a uint32)

func (ColorImage) Width

func (c ColorImage) Width() int

type ColorModel

type ColorModel interface {
	Convert(c Color) Color
}

A ColorModel can convert foreign Colors, with a possible loss of precision, to a Color from its own color model.

var AlphaColorModel ColorModel = ColorModelFunc(toAlphaColor)

The ColorModel associated with AlphaColor.

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

type ColorModelFunc func(Color) Color

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 Image

type Image interface {
	ColorModel() ColorModel
	Width() int
	Height() int
	// At(0, 0) returns the upper-left pixel of the grid.
	// At(Width()-1, Height()-1) returns the lower-right pixel.
	At(x, y int) Color
}

An Image is a rectangular grid of Colors drawn from a ColorModel.

type NRGBA

type NRGBA struct {
	// The Pixel field's indices are y first, then x, so that At(x, y) == Pixel[y][x].
	Pixel [][]NRGBAColor
}

A NRGBA is an in-memory image backed by a 2-D slice of NRGBAColor values.

func NewNRGBA

func NewNRGBA(w, h int) *NRGBA

NewNRGBA returns a new NRGBA with the given width and height.

func (*NRGBA) At

func (p *NRGBA) At(x, y int) Color

func (*NRGBA) ColorModel

func (p *NRGBA) ColorModel() ColorModel

func (*NRGBA) Height

func (p *NRGBA) Height() int

func (*NRGBA) Set

func (p *NRGBA) Set(x, y int, c Color)

func (*NRGBA) Width

func (p *NRGBA) Width() int

type NRGBA64

type NRGBA64 struct {
	// The Pixel field's indices are y first, then x, so that At(x, y) == Pixel[y][x].
	Pixel [][]NRGBA64Color
}

A NRGBA64 is an in-memory image backed by a 2-D slice of NRGBA64Color values.

func NewNRGBA64

func NewNRGBA64(w, h int) *NRGBA64

NewNRGBA64 returns a new NRGBA64 with the given width and height.

func (*NRGBA64) At

func (p *NRGBA64) At(x, y int) Color

func (*NRGBA64) ColorModel

func (p *NRGBA64) ColorModel() ColorModel

func (*NRGBA64) Height

func (p *NRGBA64) Height() int

func (*NRGBA64) Set

func (p *NRGBA64) Set(x, y int, c Color)

func (*NRGBA64) Width

func (p *NRGBA64) Width() int

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 {
	// The Pixel field's indices are y first, then x, so that At(x, y) == Palette[Pixel[y][x]].
	Pixel   [][]uint8
	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) At

func (p *Paletted) At(x, y int) Color

func (*Paletted) ColorIndexAt

func (p *Paletted) ColorIndexAt(x, y int) uint8

func (*Paletted) ColorModel

func (p *Paletted) ColorModel() ColorModel

func (*Paletted) Height

func (p *Paletted) Height() int

func (*Paletted) SetColorIndex

func (p *Paletted) SetColorIndex(x, y int, index uint8)

func (*Paletted) Width

func (p *Paletted) Width() int

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 RGBA

type RGBA struct {
	// The Pixel field's indices are y first, then x, so that At(x, y) == Pixel[y][x].
	Pixel [][]RGBAColor
}

An RGBA is an in-memory image backed by a 2-D slice of RGBAColor values.

func NewRGBA

func NewRGBA(w, h int) *RGBA

NewRGBA returns a new RGBA with the given width and height.

func (*RGBA) At

func (p *RGBA) At(x, y int) Color

func (*RGBA) ColorModel

func (p *RGBA) ColorModel() ColorModel

func (*RGBA) Height

func (p *RGBA) Height() int

func (*RGBA) Set

func (p *RGBA) Set(x, y int, c Color)

func (*RGBA) Width

func (p *RGBA) Width() int

type RGBA64

type RGBA64 struct {
	// The Pixel field's indices are y first, then x, so that At(x, y) == Pixel[y][x].
	Pixel [][]RGBA64Color
}

An RGBA64 is an in-memory image backed by a 2-D slice of RGBA64Color values.

func NewRGBA64

func NewRGBA64(w, h int) *RGBA64

NewRGBA64 returns a new RGBA64 with the given width and height.

func (*RGBA64) At

func (p *RGBA64) At(x, y int) Color

func (*RGBA64) ColorModel

func (p *RGBA64) ColorModel() ColorModel

func (*RGBA64) Height

func (p *RGBA64) Height() int

func (*RGBA64) Set

func (p *RGBA64) Set(x, y int, c Color)

func (*RGBA64) Width

func (p *RGBA64) Width() int

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.

func (RGBAColor) RGBA

func (c RGBAColor) RGBA() (r, g, b, a uint32)

Directories

Path Synopsis
The jpeg package implements a decoder for JPEG images, as defined in ITU-T T.81.
The jpeg package implements a decoder for JPEG images, as defined in ITU-T T.81.
The png package implements a PNG image decoder and encoder.
The png package implements a PNG image decoder and encoder.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL