images

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: BSD-3-Clause Imports: 2 Imported by: 1

Documentation

Overview

Package images provides image formats useful for embedded programming that are unavailable in the standard image package.

Index

Constants

View Source
const (
	// Nearest means nearest-neighbor scaling. Use if the pixelated look of the
	// scaled image is acceptable or desirable.
	Nearest byte = iota

	// Bilinear means bilinear interpolation. Use if the pixelated look of the
	// Nearest is undesirable.
	Bilinear
)

Scaling mode.

View Source
const (
	MI = 0         // identity (no operation)
	MV = 1 << iota // swap X with Y
	MX             // mirror X axis
	MY             // mirror Y axis
)

Variables

View Source
var (
	RGBModel   = color.ModelFunc(rgbModel)
	RGB16Model = color.ModelFunc(rgb16Model)
)
View Source
var MonoModel = color.ModelFunc(monoModel)

Functions

This section is empty.

Types

type AlphaN

type AlphaN struct {
	Rect   image.Rectangle // image bounds
	Stride int             // stride (in bytes) between vertically adjacent pixels
	LogN   uint8           // 1<<LogN is the number of bits per pixel
	Shift  uint8           // the bit offest in Pix[0] to the first pixel
	Pix    []uint8         // the image pixels
}

AlphaN is an in-memory image whose At method returns color.Alpha with 1, 2, 4 or 8 bit precision.

func NewAlphaN

func NewAlphaN(r image.Rectangle, nbpp int) *AlphaN

NewAlphaN returns a new AlphaN image with the given bounds and number of bits per pixel.

func (*AlphaN) AlphaAt

func (p *AlphaN) AlphaAt(x, y int) color.Alpha

func (*AlphaN) At

func (p *AlphaN) At(x, y int) color.Color

func (*AlphaN) Bounds

func (p *AlphaN) Bounds() image.Rectangle

func (*AlphaN) ColorModel

func (p *AlphaN) ColorModel() color.Model

func (*AlphaN) PixOffset

func (p *AlphaN) PixOffset(x, y int) (offset int, shift uint)

PixOffset returns the index of the first element of Pix that corresponds to the pixel at (x, y) and the index to the bits in that element that determines the pixel value.

func (*AlphaN) RGBA64At

func (p *AlphaN) RGBA64At(x, y int) color.RGBA64

func (*AlphaN) Set

func (p *AlphaN) Set(x, y int, c color.Color)

func (*AlphaN) SetAlpha

func (p *AlphaN) SetAlpha(x, y int, c color.Alpha)

func (*AlphaN) SetRGBA64

func (p *AlphaN) SetRGBA64(x, y int, c color.RGBA64)

func (*AlphaN) SubImage

func (p *AlphaN) SubImage(r image.Rectangle) image.Image

SubImage returns an image representing the portion of the image p visible through r. The returned value shares pixels with the original image.

type AlphaNModel

type AlphaNModel uint8

AlphaNModel is a color model for n-bit transparency

const (
	Alpha1Model AlphaNModel = 1 // 2 levels of transparency
	Alpha2Model AlphaNModel = 2 // 4 levels of transparency
	Alpha4Model AlphaNModel = 4 // 16 levels of transparency
	Alpha8Model AlphaNModel = 8 // 256 levels of transparency
)

func (AlphaNModel) Convert

func (m AlphaNModel) Convert(c color.Color) color.Color

type ImmAlphaN

type ImmAlphaN struct {
	Rect   image.Rectangle // image bounds
	Stride int             // stride (in bytes) between vertically adjacent pixels
	LogN   uint8           // 1<<LogN is the number of bits per pixel
	Shift  uint8           // the bit offest in Pix[0] to the first pixel
	Pix    string          // the image pixels
}

ImmAlphaN is an immutable counterpart of AlphaN.

func NewImmAlphaN

func NewImmAlphaN(r image.Rectangle, nbpp int, bits string) *ImmAlphaN

NewImmAlphaN returns a new ImmAlpha image with the given bounds and content.

func (*ImmAlphaN) AlphaAt

func (p *ImmAlphaN) AlphaAt(x, y int) color.Alpha

func (*ImmAlphaN) At

func (p *ImmAlphaN) At(x, y int) color.Color

func (*ImmAlphaN) Bounds

func (p *ImmAlphaN) Bounds() image.Rectangle

func (*ImmAlphaN) ColorModel

func (p *ImmAlphaN) ColorModel() color.Model

func (*ImmAlphaN) PixOffset

func (p *ImmAlphaN) PixOffset(x, y int) (offset int, shift uint)

PixOffset returns the index of the first element of Pix that corresponds to the pixel at (x, y) and the index to the bits in that element that determines the pixel value.

func (*ImmAlphaN) RGBA64At

func (p *ImmAlphaN) RGBA64At(x, y int) color.RGBA64

func (*ImmAlphaN) SubImage

func (p *ImmAlphaN) SubImage(r image.Rectangle) image.Image

SubImage returns an image representing the portion of the image p visible through r. The returned value shares pixels with the original image.

type ImmRGB

type ImmRGB struct {
	Rect   image.Rectangle // image bounds
	Stride int             // stride (in bytes) between vertically adjacent pixels
	Pix    string          // the image pixels
}

ImmRGB is an immutable counterpart of RGB.

func NewImmRGB

func NewImmRGB(r image.Rectangle, bits string) *ImmRGB

NewImmRGB returns a new ImmRGB image with the given bounds and content

func (*ImmRGB) At

func (p *ImmRGB) At(x, y int) color.Color

func (*ImmRGB) Bounds

func (p *ImmRGB) Bounds() image.Rectangle

func (*ImmRGB) ColorModel

func (p *ImmRGB) ColorModel() color.Model

func (*ImmRGB) Opaque

func (p *ImmRGB) Opaque() bool

func (*ImmRGB) PixOffset

func (p *ImmRGB) PixOffset(x, y int) int

PixOffset returns the index of the first element of Pix that corresponds to the pixel at (x, y).

func (*ImmRGB) RGBA64At

func (p *ImmRGB) RGBA64At(x, y int) color.RGBA64

func (*ImmRGB) RGBAAt

func (p *ImmRGB) RGBAAt(x, y int) color.RGBA

func (*ImmRGB) SubImage

func (p *ImmRGB) SubImage(r image.Rectangle) image.Image

SubImage returns an image representing the portion of the image p visible through r. The returned value shares pixels with the original image.

type ImmRGB16

type ImmRGB16 struct {
	Rect   image.Rectangle // image bounds
	Stride int             // stride (in bytes) between vertically adjacent pixels
	Pix    string          // the image pixels
}

ImmRGB16 is an immutable counterpart of RGB16.

func NewImmRGB16

func NewImmRGB16(r image.Rectangle, bits string) *ImmRGB16

NewImmRGB16 returns a new ImmRGB16 image with the given bounds and content.

func (*ImmRGB16) At

func (p *ImmRGB16) At(x, y int) color.Color

func (*ImmRGB16) Bounds

func (p *ImmRGB16) Bounds() image.Rectangle

func (*ImmRGB16) ColorModel

func (p *ImmRGB16) ColorModel() color.Model

func (*ImmRGB16) Opaque

func (p *ImmRGB16) Opaque() bool

func (*ImmRGB16) PixOffset

func (p *ImmRGB16) PixOffset(x, y int) int

PixOffset returns the index of the first element of Pix that corresponds to the pixel at (x, y).

func (*ImmRGB16) RGBAAt

func (p *ImmRGB16) RGBAAt(x, y int) color.RGBA

func (*ImmRGB16) SubImage

func (p *ImmRGB16) SubImage(r image.Rectangle) image.Image

SubImage returns an image representing the portion of the image p visible through r. The returned value shares pixels with the original image.

type Magnifier

type Magnifier struct {
	Image  image.Image
	Sx, Sy int  // scaling factors along X and Y axes
	Mode   byte // scaling mode: Nearest or Bilinear
}

Magnifier can be used to wrap an image to scale it up at runtime by integer factor.

func Magnify

func Magnify(img image.Image, sx, sy int, mode byte) *Magnifier

Magnify wraps img into Magnifier to scale it up by scale factor usind given scaling mode.

func (*Magnifier) At

func (p *Magnifier) At(x, y int) color.Color

At implements image.Image interface.

func (*Magnifier) Bounds

func (p *Magnifier) Bounds() image.Rectangle

Bounds implements image.Image interface.

func (*Magnifier) ColorModel

func (p *Magnifier) ColorModel() color.Model

ColorModel implements image.Image interface.

func (*Magnifier) RGBA64At

func (p *Magnifier) RGBA64At(x, y int) color.RGBA64

RGBA64At implements image.RGBA64Image interface.

type Mirror

type Mirror struct {
	Image image.Image
	Mode  int
}

Mirror can be used to wrap an image to reflect it through three different axes: (0, t) for MX, (t, 0) for MY and (t, t) for MV (parentheses contain parametric descriptions of axes).

func NewMirror

func NewMirror(img image.Image, mvxy int) *Mirror

func (*Mirror) At

func (p *Mirror) At(x, y int) color.Color

At implements image.Image interface.

func (*Mirror) Bounds

func (p *Mirror) Bounds() image.Rectangle

Bounds implements image.Image interface.

func (*Mirror) ColorModel

func (p *Mirror) ColorModel() color.Model

ColorModel implements image.Image interface.

func (*Mirror) RGBA64At

func (p *Mirror) RGBA64At(x, y int) color.RGBA64

RGBA64At implements image.RGBA64Image interface.

type Mono

type Mono struct {
	Rect   image.Rectangle // image bounds
	Stride int             // stride (in bytes) between vertically adjacent pixels
	Shift  uint            // the bit offest in Pix[0] to the first pixel
	Pix    []byte          // the image pixels
}

Mono is an in-memory image whose At method returns color.Gray with two possible values: 0 or 255.

func NewMono

func NewMono(r image.Rectangle) *Mono

NewMono returns a new Mono image.

func (*Mono) At

func (p *Mono) At(x, y int) color.Color

func (*Mono) Bounds

func (p *Mono) Bounds() image.Rectangle

func (*Mono) ColorModel

func (p *Mono) ColorModel() color.Model

func (*Mono) GrayAt

func (p *Mono) GrayAt(x, y int) color.Gray

func (*Mono) PixOffset

func (p *Mono) PixOffset(x, y int) (offset int, shift uint)

PixOffset returns the index of the first element of Pix that corresponds to the pixel at (x, y) and the index to the bit in that element that determines the pixel value.

func (*Mono) RGBA64At

func (p *Mono) RGBA64At(x, y int) color.RGBA64

func (*Mono) Set

func (p *Mono) Set(x, y int, c color.Color)

func (*Mono) SetGray

func (p *Mono) SetGray(x, y int, c color.Gray)

func (*Mono) SetRGBA64

func (p *Mono) SetRGBA64(x, y int, c color.RGBA64)

type RGB

type RGB struct {
	Rect   image.Rectangle // image bounds
	Stride int             // stride (in bytes) between vertically adjacent pixels
	Pix    []uint8         // the image pixels
}

RGB is an in-memory image whose At method returns RGB values.

func NewRGB

func NewRGB(r image.Rectangle) *RGB

NewRGB returns a new RGB image with the given bounds.

func (*RGB) At

func (p *RGB) At(x, y int) color.Color

func (*RGB) Bounds

func (p *RGB) Bounds() image.Rectangle

func (*RGB) ColorModel

func (p *RGB) ColorModel() color.Model

func (*RGB) Opaque

func (p *RGB) Opaque() bool

func (*RGB) PixOffset

func (p *RGB) PixOffset(x, y int) int

PixOffset returns the index of the first element of Pix that corresponds to the pixel at (x, y).

func (*RGB) RGBA64At

func (p *RGB) RGBA64At(x, y int) color.RGBA64

func (*RGB) RGBAAt

func (p *RGB) RGBAAt(x, y int) color.RGBA

func (*RGB) Set

func (p *RGB) Set(x, y int, c color.Color)

func (*RGB) SetRGBA

func (p *RGB) SetRGBA(x, y int, c color.RGBA)

func (*RGB) SetRGBA64

func (p *RGB) SetRGBA64(x, y int, c color.RGBA64)

func (*RGB) SubImage

func (p *RGB) SubImage(r image.Rectangle) image.Image

SubImage returns an image representing the portion of the image p visible through r. The returned value shares pixels with the original image.

type RGB16

type RGB16 struct {
	Rect   image.Rectangle // image bounds
	Stride int             // stride (in bytes) between vertically adjacent pixels
	Pix    []uint8         // the image pixels
}

RGB16 is an in-memory image whose At method returns RGB16 values.

func NewRGB16

func NewRGB16(r image.Rectangle) *RGB16

NewRGB16 returns a new RGB16 image with the given bounds.

func (*RGB16) At

func (p *RGB16) At(x, y int) color.Color

func (*RGB16) Bounds

func (p *RGB16) Bounds() image.Rectangle

func (*RGB16) ColorModel

func (p *RGB16) ColorModel() color.Model

func (*RGB16) Opaque

func (p *RGB16) Opaque() bool

func (*RGB16) PixOffset

func (p *RGB16) PixOffset(x, y int) int

PixOffset returns the index of the first element of Pix that corresponds to the pixel at (x, y).

func (*RGB16) RGBA64At

func (p *RGB16) RGBA64At(x, y int) color.RGBA64

func (*RGB16) RGBAAt

func (p *RGB16) RGBAAt(x, y int) color.RGBA

func (*RGB16) Set

func (p *RGB16) Set(x, y int, c color.Color)

func (*RGB16) SetRGBA

func (p *RGB16) SetRGBA(x, y int, c color.RGBA)

func (*RGB16) SetRGBA64

func (p *RGB16) SetRGBA64(x, y int, c color.RGBA64)

func (*RGB16) SubImage

func (p *RGB16) SubImage(r image.Rectangle) image.Image

SubImage returns an image representing the portion of the image p visible through r. The returned value shares pixels with the original image.

Jump to

Keyboard shortcuts

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