...

Package imageutil

Overview ▾

Package imageutil provides utility functions, structures and interfaces that allows to operate on images. The function NewImage creates a new Image implementation based on provided input parameters. The functions ColorXXXAt allows to get the the colors from provided data and parameters without the need of creating image abstraction. Image converters allows to convert between different color spaces. As Image interface implements also image.Image it was possible to use standard golang image.Image as an input for the converters.

Index ▾

Variables
func AddDataPadding(width, height, bitsPerComponent, colorComponents int, data []byte) ([]byte, error)
func AutoThresholdTriangle(histogram [256]int) uint8
func BytesPerLine(width, bitsPerComponent, colorComponents int) int
func ColorAt(x, y, width, bitsPerColor, colorComponents, bytesPerLine int, data, alpha []byte, decode []float64) (color.Color, error)
func ColorAtCMYK(x, y, width int, data []byte, decode []float64) (color.CMYK, error)
func ColorAtGray16BPC(x, y, bytesPerLine int, data []byte, decode []float64) (color.Gray16, error)
func ColorAtGray1BPC(x, y, bytesPerLine int, data []byte, decode []float64) (color.Gray, error)
func ColorAtGray2BPC(x, y, bytesPerLine int, data []byte, decode []float64) (color.Gray, error)
func ColorAtGray4BPC(x, y, bytesPerLine int, data []byte, decode []float64) (color.Gray, error)
func ColorAtGray8BPC(x, y, bytesPerLine int, data []byte, decode []float64) (color.Gray, error)
func ColorAtGrayscale(x, y, bitsPerColor, bytesPerLine int, data []byte, decode []float64) (color.Color, error)
func ColorAtNRGBA(x, y, width, bytesPerLine, bitsPerColor int, data, alpha []byte, decode []float64) (color.Color, error)
func ColorAtNRGBA16(x, y, width, bytesPerLine int, data, alpha []byte, decode []float64) (color.NRGBA, error)
func ColorAtNRGBA32(x, y, width int, data, alpha []byte, decode []float64) (color.NRGBA, error)
func ColorAtNRGBA64(x, y, width int, data, alpha []byte, decode []float64) (color.NRGBA64, error)
func GrayHistogram(g Gray) (histogram [256]int)
func ImgToBinary(i image.Image, threshold uint8) *image.Gray
func ImgToGray(i image.Image) *image.Gray
func IsGrayImgBlackAndWhite(i *image.Gray) bool
func LinearInterpolate(x, xmin, xmax, ymin, ymax float64) float64
func MonochromeModel(threshold uint8) color.Model
type CMYK
type CMYK32
    func (i *CMYK32) At(x, y int) color.Color
    func (i *CMYK32) Base() *ImageBase
    func (i *CMYK32) Bounds() image.Rectangle
    func (i *CMYK32) CMYKAt(x, y int) color.CMYK
    func (i *CMYK32) ColorAt(x, y int) (color.Color, error)
    func (i *CMYK32) ColorModel() color.Model
    func (i *CMYK32) Copy() Image
    func (i *CMYK32) Set(x, y int, c color.Color)
    func (i *CMYK32) SetCMYK(x, y int, c color.CMYK)
    func (i *CMYK32) Validate() error
type ColorConverter
    func ConverterFunc(converterFunc func(img image.Image) (Image, error)) ColorConverter
    func GetConverter(bitsPerComponent, colorComponents int) (ColorConverter, error)
    func MonochromeThresholdConverter(threshold uint8) ColorConverter
type Gray
type Gray16
    func (i *Gray16) At(x, y int) color.Color
    func (i *Gray16) Base() *ImageBase
    func (i *Gray16) Bounds() image.Rectangle
    func (i *Gray16) ColorAt(x, y int) (color.Color, error)
    func (i *Gray16) ColorModel() color.Model
    func (i *Gray16) Copy() Image
    func (i *Gray16) GrayAt(x, y int) color.Gray
    func (i *Gray16) Histogram() (histogram [256]int)
    func (i *Gray16) Set(x, y int, c color.Color)
    func (i *Gray16) SetGray(x, y int, g color.Gray)
    func (i *Gray16) Validate() error
type Gray2
    func (i *Gray2) At(x, y int) color.Color
    func (i *Gray2) Base() *ImageBase
    func (i *Gray2) Bounds() image.Rectangle
    func (i *Gray2) ColorAt(x, y int) (color.Color, error)
    func (i *Gray2) ColorModel() color.Model
    func (i *Gray2) Copy() Image
    func (i *Gray2) GrayAt(x, y int) color.Gray
    func (i *Gray2) Histogram() (histogram [256]int)
    func (i *Gray2) Set(x, y int, c color.Color)
    func (i *Gray2) SetGray(x, y int, gray color.Gray)
    func (i *Gray2) Validate() error
type Gray4
    func (i *Gray4) At(x, y int) color.Color
    func (i *Gray4) Base() *ImageBase
    func (i *Gray4) Bounds() image.Rectangle
    func (i *Gray4) ColorAt(x, y int) (color.Color, error)
    func (i *Gray4) ColorModel() color.Model
    func (i *Gray4) Copy() Image
    func (i *Gray4) GrayAt(x, y int) color.Gray
    func (i *Gray4) Histogram() (histogram [256]int)
    func (i *Gray4) Set(x, y int, c color.Color)
    func (i *Gray4) SetGray(x, y int, g color.Gray)
    func (i *Gray4) Validate() error
type Gray8
    func (i *Gray8) At(x, y int) color.Color
    func (i *Gray8) Base() *ImageBase
    func (i *Gray8) Bounds() image.Rectangle
    func (i *Gray8) ColorAt(x, y int) (color.Color, error)
    func (i *Gray8) ColorModel() color.Model
    func (i *Gray8) Copy() Image
    func (i *Gray8) GrayAt(x, y int) color.Gray
    func (i *Gray8) Histogram() (histogram [256]int)
    func (i *Gray8) Set(x, y int, c color.Color)
    func (i *Gray8) SetGray(x, y int, g color.Gray)
    func (i *Gray8) Validate() error
type Histogramer
type Image
    func FromGoImage(i image.Image) (Image, error)
    func NewImage(width, height, bitsPerComponent, colorComponents int, data, alpha []byte, decode []float64) (Image, error)
type ImageBase
    func NewImageBase(width int, height int, bitsPerComponent int, colorComponents int, data []byte, alpha []byte, decode []float64) ImageBase
    func (i *ImageBase) GetAlpha() []byte
    func (i *ImageBase) HasAlpha() bool
    func (i *ImageBase) MakeAlpha()
    func (i *ImageBase) Pix() []byte
type Monochrome
    func (m *Monochrome) At(x, y int) color.Color
    func (m *Monochrome) Base() *ImageBase
    func (m *Monochrome) Bounds() image.Rectangle
    func (m *Monochrome) ColorAt(x, y int) (color.Color, error)
    func (m *Monochrome) ColorModel() color.Model
    func (m *Monochrome) Copy() Image
    func (m *Monochrome) GrayAt(x, y int) color.Gray
    func (m *Monochrome) Histogram() (histogram [256]int)
    func (m *Monochrome) Set(x, y int, c color.Color)
    func (m *Monochrome) SetGray(x, y int, g color.Gray)
    func (m *Monochrome) Validate() error
type NRGBA
type NRGBA16
    func (i *NRGBA16) At(x, y int) color.Color
    func (i *NRGBA16) Base() *ImageBase
    func (i *NRGBA16) Bounds() image.Rectangle
    func (i *NRGBA16) ColorAt(x, y int) (color.Color, error)
    func (i *NRGBA16) ColorModel() color.Model
    func (i *NRGBA16) Copy() Image
    func (i *NRGBA16) NRGBAAt(x, y int) color.NRGBA
    func (i *NRGBA16) Set(x, y int, c color.Color)
    func (i *NRGBA16) SetNRGBA(x, y int, c color.NRGBA)
    func (i *NRGBA16) Validate() error
type NRGBA32
    func (i *NRGBA32) At(x, y int) color.Color
    func (i *NRGBA32) Base() *ImageBase
    func (i *NRGBA32) Bounds() image.Rectangle
    func (i *NRGBA32) ColorAt(x, y int) (color.Color, error)
    func (i *NRGBA32) ColorModel() color.Model
    func (i *NRGBA32) Copy() Image
    func (i *NRGBA32) NRGBAAt(x, y int) color.NRGBA
    func (i *NRGBA32) Set(x, y int, c color.Color)
    func (i *NRGBA32) SetNRGBA(x, y int, c color.NRGBA)
    func (i *NRGBA32) Validate() error
type NRGBA64
    func (i *NRGBA64) At(x, y int) color.Color
    func (i *NRGBA64) Base() *ImageBase
    func (i *NRGBA64) Bounds() image.Rectangle
    func (i *NRGBA64) ColorAt(x, y int) (color.Color, error)
    func (i *NRGBA64) ColorModel() color.Model
    func (i *NRGBA64) Copy() Image
    func (i *NRGBA64) NRGBA64At(x, y int) color.NRGBA64
    func (i *NRGBA64) Set(x, y int, c color.Color)
    func (i *NRGBA64) SetNRGBA64(x, y int, c color.NRGBA64)
    func (i *NRGBA64) Validate() error
type RGBA
type SMasker

Package files

cmyk.go colors.go doc.go grayscale.go image.go interpolate.go padding.go rgb.go rgbtobw.go

Variables

Converter implementations.

var (
    MonochromeConverter = ConverterFunc(monochromeTriangleConverter)
    Gray2Converter      = ConverterFunc(gray2Converter)
    Gray4Converter      = ConverterFunc(gray4Converter)
    GrayConverter       = ConverterFunc(grayConverter)
    Gray16Converter     = ConverterFunc(gray16Converter)
    NRGBA16Converter    = ConverterFunc(nrgba16Converter)
    NRGBAConverter      = ConverterFunc(nrgbaConverter)
    NRGBA64Converter    = ConverterFunc(nrgba64Converter)
    CMYKConverter       = ConverterFunc(cmykConverter)
)

Additional models for images.

var (
    Gray2Model   = color.ModelFunc(gray2Model)
    Gray4Model   = color.ModelFunc(gray4Model)
    NRGBA16Model = color.ModelFunc(nrgba16Model)
)

ErrInvalidImage is an error used when provided image is invalid.

var ErrInvalidImage = errors.New("invalid image data size for provided dimensions")

func AddDataPadding

func AddDataPadding(width, height, bitsPerComponent, colorComponents int, data []byte) ([]byte, error)

AddDataPadding adds the row bit padding to the given data slice if it is required by the image parameters.

func AutoThresholdTriangle

func AutoThresholdTriangle(histogram [256]int) uint8

AutoThresholdTriangle is a function that returns threshold value on the base of provided histogram. It is calculated using triangle method.

func BytesPerLine

func BytesPerLine(width, bitsPerComponent, colorComponents int) int

BytesPerLine gets the number of bytes per line for given width, bits per color and color components number.

func ColorAt

func ColorAt(x, y, width, bitsPerColor, colorComponents, bytesPerLine int, data, alpha []byte, decode []float64) (color.Color, error)

ColorAt gets the color of the image with provided parameters.

Parameters:
	x				- horizontal coordinate of the pixel.
	y				- vertical coordinate of the pixel.
	width			- the width of the image.
	bitsPerColor	- number of bits per color component.
	colorComponents	- number of color components per pixel.
	bytesPerLine	- number of bytes per line.
	data			- byte slice data for given image.
	alpha			- (optional) the alpha part data slice of the image.

func ColorAtCMYK

func ColorAtCMYK(x, y, width int, data []byte, decode []float64) (color.CMYK, error)

ColorAtCMYK gets the color at CMYK32 colorspace at 'x' and 'y' position for an image with specific 'width'.

func ColorAtGray16BPC

func ColorAtGray16BPC(x, y, bytesPerLine int, data []byte, decode []float64) (color.Gray16, error)

ColorAtGray16BPC gets the color of image in grayscale color space with 8 bits per component specific 'width', 'bytesPerLine' and 'data' at the 'x' and 'y' coordinates position.

func ColorAtGray1BPC

func ColorAtGray1BPC(x, y, bytesPerLine int, data []byte, decode []float64) (color.Gray, error)

ColorAtGray1BPC gets the color of image in grayscale color space with one bit per component specific 'width', 'bytesPerLine' and 'data' at the 'x' and 'y' coordinates position.

func ColorAtGray2BPC

func ColorAtGray2BPC(x, y, bytesPerLine int, data []byte, decode []float64) (color.Gray, error)

ColorAtGray2BPC gets the color of image in grayscale color space with two bits per component specific 'width', 'bytesPerLine' and 'data' at the 'x' and 'y' coordinates position.

func ColorAtGray4BPC

func ColorAtGray4BPC(x, y, bytesPerLine int, data []byte, decode []float64) (color.Gray, error)

ColorAtGray4BPC gets the color of image in grayscale color space with 4 bits per component specific 'width', 'bytesPerLine' and 'data' at the 'x' and 'y' coordinates position.

func ColorAtGray8BPC

func ColorAtGray8BPC(x, y, bytesPerLine int, data []byte, decode []float64) (color.Gray, error)

ColorAtGray8BPC gets the color of image in grayscale color space with 8 bits per component specific 'width', 'bytesPerLine' and 'data' at the 'x' and 'y' coordinates position.

func ColorAtGrayscale

func ColorAtGrayscale(x, y, bitsPerColor, bytesPerLine int, data []byte, decode []float64) (color.Color, error)

ColorAtGrayscale gets the color of the grayscale image with specific 'width', 'bitsPerColor' and 'data' at the 'x' and 'y' coordinates position.

func ColorAtNRGBA

func ColorAtNRGBA(x, y, width, bytesPerLine, bitsPerColor int, data, alpha []byte, decode []float64) (color.Color, error)

ColorAtNRGBA gets the color of the image with specific 'width' and 'bitsPerColor' at 'x' and 'y' coordinates. The 'data' defines image data and optional 'alpha' alpha component of the color.

func ColorAtNRGBA16

func ColorAtNRGBA16(x, y, width, bytesPerLine int, data, alpha []byte, decode []float64) (color.NRGBA, error)

ColorAtNRGBA16 gets the 4 bit per component NRGBA32 color at 'x', 'y' coordinates.

func ColorAtNRGBA32

func ColorAtNRGBA32(x, y, width int, data, alpha []byte, decode []float64) (color.NRGBA, error)

ColorAtNRGBA32 gets the 8 bit per component NRGBA32 color at 'x', 'y'.

func ColorAtNRGBA64

func ColorAtNRGBA64(x, y, width int, data, alpha []byte, decode []float64) (color.NRGBA64, error)

ColorAtNRGBA64 gets 16 bit per component NRGBA64 color.

func GrayHistogram

func GrayHistogram(g Gray) (histogram [256]int)

GrayHistogram gets histogram for the provided Gray image.

func ImgToBinary

func ImgToBinary(i image.Image, threshold uint8) *image.Gray

ImgToBinary gets the binary (black/white) image from the given image 'i' and provided threshold 'threshold'

func ImgToGray

func ImgToGray(i image.Image) *image.Gray

ImgToGray gets the gray-scaled image from the given 'i' image.

func IsGrayImgBlackAndWhite

func IsGrayImgBlackAndWhite(i *image.Gray) bool

IsGrayImgBlackAndWhite checks if provided gray image is BlackAndWhite - Binary image.

func LinearInterpolate

func LinearInterpolate(x, xmin, xmax, ymin, ymax float64) float64

LinearInterpolate is the simple linear interpolation from the PDF manual - PDF 32000-1:2008 - 7.10.2.

func MonochromeModel

func MonochromeModel(threshold uint8) color.Model

MonochromeModel is the monochrome color Model that relates on given threshold.

type CMYK

CMYK is the interface used for getting and operation on the CMYK interface.

type CMYK interface {
    CMYKAt(x, y int) color.CMYK
    SetCMYK(x, y int, c color.CMYK)
}

type CMYK32

CMYK32 is an Image implementation for the CMYK32 color colorConverter.

type CMYK32 struct {
    ImageBase
}

func (*CMYK32) At

func (i *CMYK32) At(x, y int) color.Color

At implements image.Image interface.

func (*CMYK32) Base

func (i *CMYK32) Base() *ImageBase

Base implements Image interface.

func (*CMYK32) Bounds

func (i *CMYK32) Bounds() image.Rectangle

Bounds implements image.Image interface.

func (*CMYK32) CMYKAt

func (i *CMYK32) CMYKAt(x, y int) color.CMYK

CMYKAt implements CMYK interface.

func (*CMYK32) ColorAt

func (i *CMYK32) ColorAt(x, y int) (color.Color, error)

ColorAt implements Image interface.

func (*CMYK32) ColorModel

func (i *CMYK32) ColorModel() color.Model

ColorModel implements image.Image interface.

func (*CMYK32) Copy

func (i *CMYK32) Copy() Image

Copy implements Image interface.

func (*CMYK32) Set

func (i *CMYK32) Set(x, y int, c color.Color)

Set implements draw.Image interface.

func (*CMYK32) SetCMYK

func (i *CMYK32) SetCMYK(x, y int, c color.CMYK)

SetCMYK implements CMYK interface.

func (*CMYK32) Validate

func (i *CMYK32) Validate() error

Validate implements Image interface.

type ColorConverter

ColorConverter is an interface that allows to convert images between different color spaces.

type ColorConverter interface {
    // Convert converts images to given color colorConverter.
    Convert(src image.Image) (Image, error)
}

func ConverterFunc

func ConverterFunc(converterFunc func(img image.Image) (Image, error)) ColorConverter

ConverterFunc creates new colorConverter based on the provided 'paletteFunc'.

func GetConverter

func GetConverter(bitsPerComponent, colorComponents int) (ColorConverter, error)

GetConverter gets the color converter for given bits per component (bit depth) and color components parameters.

func MonochromeThresholdConverter

func MonochromeThresholdConverter(threshold uint8) ColorConverter

MonochromeThresholdConverter creates a new monochrome colorConverter.

type Gray

Gray is an interface that allows to get and set color.Gray for grayscale images.

type Gray interface {
    GrayAt(x, y int) color.Gray
    SetGray(x, y int, g color.Gray)
}

type Gray16

Gray16 is a grayscale image where gray pixel is of 16-bit size.

type Gray16 struct {
    ImageBase
}

func (*Gray16) At

func (i *Gray16) At(x, y int) color.Color

At implements image.Image interface.

func (*Gray16) Base

func (i *Gray16) Base() *ImageBase

Base implements Image interface.

func (*Gray16) Bounds

func (i *Gray16) Bounds() image.Rectangle

Bounds implements image.Image interface.

func (*Gray16) ColorAt

func (i *Gray16) ColorAt(x, y int) (color.Color, error)

ColorAt implements Image interface.

func (*Gray16) ColorModel

func (i *Gray16) ColorModel() color.Model

ColorModel implements image.Image interface.

func (*Gray16) Copy

func (i *Gray16) Copy() Image

Copy implements Image interface.

func (*Gray16) GrayAt

func (i *Gray16) GrayAt(x, y int) color.Gray

GrayAt implements Gray interface.

func (*Gray16) Histogram

func (i *Gray16) Histogram() (histogram [256]int)

Histogram implements Histogramer interface.

func (*Gray16) Set

func (i *Gray16) Set(x, y int, c color.Color)

Set implements draw.Image interface.

func (*Gray16) SetGray

func (i *Gray16) SetGray(x, y int, g color.Gray)

SetGray implements Gray interface.

func (*Gray16) Validate

func (i *Gray16) Validate() error

Validate implements Image interface.

type Gray2

Gray2 is a 2-bit base grayscale image. It implements image.Image, draw.Image, Image and Gray interfaces.

type Gray2 struct {
    ImageBase
}

func (*Gray2) At

func (i *Gray2) At(x, y int) color.Color

At implements image.Image interface.

func (*Gray2) Base

func (i *Gray2) Base() *ImageBase

Base implements Image interface.

func (*Gray2) Bounds

func (i *Gray2) Bounds() image.Rectangle

Bounds implements

func (*Gray2) ColorAt

func (i *Gray2) ColorAt(x, y int) (color.Color, error)

ColorAt implements Image interface.

func (*Gray2) ColorModel

func (i *Gray2) ColorModel() color.Model

ColorModel implements image.Image interface.

func (*Gray2) Copy

func (i *Gray2) Copy() Image

Copy implements Image interface.

func (*Gray2) GrayAt

func (i *Gray2) GrayAt(x, y int) color.Gray

GrayAt implements Gray interface.

func (*Gray2) Histogram

func (i *Gray2) Histogram() (histogram [256]int)

Histogram implements Histogramer interface.

func (*Gray2) Set

func (i *Gray2) Set(x, y int, c color.Color)

Set implements draw.Image interface.

func (*Gray2) SetGray

func (i *Gray2) SetGray(x, y int, gray color.Gray)

SetGray implements Gray interface.

func (*Gray2) Validate

func (i *Gray2) Validate() error

Validate implements Image interface.

type Gray4

Gray4 is a grayscale image implementation where the gray pixel is stored in 4 bits.

type Gray4 struct {
    ImageBase
}

func (*Gray4) At

func (i *Gray4) At(x, y int) color.Color

At implements image.Image interface.

func (*Gray4) Base

func (i *Gray4) Base() *ImageBase

Base implements Image interface.

func (*Gray4) Bounds

func (i *Gray4) Bounds() image.Rectangle

Bounds implements image.Image interface.

func (*Gray4) ColorAt

func (i *Gray4) ColorAt(x, y int) (color.Color, error)

ColorAt implements Image interface.

func (*Gray4) ColorModel

func (i *Gray4) ColorModel() color.Model

ColorModel implements image.Image interface.

func (*Gray4) Copy

func (i *Gray4) Copy() Image

Copy creates a copy of given image.

func (*Gray4) GrayAt

func (i *Gray4) GrayAt(x, y int) color.Gray

GrayAt implements Gray interface.

func (*Gray4) Histogram

func (i *Gray4) Histogram() (histogram [256]int)

Histogram implements Histogramer interface.

func (*Gray4) Set

func (i *Gray4) Set(x, y int, c color.Color)

Set for given image sets color 'c' at coordinates 'x' and 'y'.

func (*Gray4) SetGray

func (i *Gray4) SetGray(x, y int, g color.Gray)

SetGray implements Gray interface.

func (*Gray4) Validate

func (i *Gray4) Validate() error

Validate implements Image interface.

type Gray8

Gray8 is a grayscale image with the gray pixel size of 8-bit.

type Gray8 struct {
    ImageBase
}

func (*Gray8) At

func (i *Gray8) At(x, y int) color.Color

At implements image.Image interface.

func (*Gray8) Base

func (i *Gray8) Base() *ImageBase

Base implements image interface.

func (*Gray8) Bounds

func (i *Gray8) Bounds() image.Rectangle

Bounds implements image.Image interface.

func (*Gray8) ColorAt

func (i *Gray8) ColorAt(x, y int) (color.Color, error)

ColorAt implements Image interface.

func (*Gray8) ColorModel

func (i *Gray8) ColorModel() color.Model

ColorModel implements image.Image interface.`

func (*Gray8) Copy

func (i *Gray8) Copy() Image

Copy implements Image interface.

func (*Gray8) GrayAt

func (i *Gray8) GrayAt(x, y int) color.Gray

GrayAt implements Gray interface.

func (*Gray8) Histogram

func (i *Gray8) Histogram() (histogram [256]int)

Histogram implements Histogramer interface.

func (*Gray8) Set

func (i *Gray8) Set(x, y int, c color.Color)

Set implements draw.Image interface.

func (*Gray8) SetGray

func (i *Gray8) SetGray(x, y int, g color.Gray)

SetGray implements Gray interface.

func (*Gray8) Validate

func (i *Gray8) Validate() error

Validate implements Image interface.

type Histogramer

Histogramer is an interface that allows to get a histogram from the image.

type Histogramer interface {
    Histogram() [256]int
}

type Image

Image is an interface used that allows to do image operations.

type Image interface {
    draw.Image
    Base() *ImageBase
    Copy() Image
    Pix() []byte
    ColorAt(x, y int) (color.Color, error)
    Validate() error
}

func FromGoImage

func FromGoImage(i image.Image) (Image, error)

FromGoImage creates a new Image from provided image 'i'.

func NewImage

func NewImage(width, height, bitsPerComponent, colorComponents int, data, alpha []byte, decode []float64) (Image, error)

NewImage creates new image for provided image parameters and image data byte slice.

type ImageBase

ImageBase is a structure that represents an bitmap image.

type ImageBase struct {
    Width, Height                     int
    BitsPerComponent, ColorComponents int
    Data, Alpha                       []byte
    Decode                            []float64
    BytesPerLine                      int
}

func NewImageBase

func NewImageBase(width int, height int, bitsPerComponent int, colorComponents int, data []byte, alpha []byte, decode []float64) ImageBase

NewImageBase creates new image base.

func (*ImageBase) GetAlpha

func (i *ImageBase) GetAlpha() []byte

GetAlpha implements SMasker interface.

func (*ImageBase) HasAlpha

func (i *ImageBase) HasAlpha() bool

HasAlpha implements SMasker interface.

func (*ImageBase) MakeAlpha

func (i *ImageBase) MakeAlpha()

MakeAlpha implements SMasker interface.

func (*ImageBase) Pix

func (i *ImageBase) Pix() []byte

Pix implements Image interface.

type Monochrome

Monochrome is a grayscale image with a 1-bit per pixel.

type Monochrome struct {
    ImageBase
    ModelThreshold uint8
}

func (*Monochrome) At

func (m *Monochrome) At(x, y int) color.Color

At implements image.Image interface.

func (*Monochrome) Base

func (m *Monochrome) Base() *ImageBase

Base implements Image interface.

func (*Monochrome) Bounds

func (m *Monochrome) Bounds() image.Rectangle

Bounds implements image.Image.

func (*Monochrome) ColorAt

func (m *Monochrome) ColorAt(x, y int) (color.Color, error)

ColorAt implements Image interface.

func (*Monochrome) ColorModel

func (m *Monochrome) ColorModel() color.Model

ColorModel implements image.Image interface.

func (*Monochrome) Copy

func (m *Monochrome) Copy() Image

Copy implements Image interface.

func (*Monochrome) GrayAt

func (m *Monochrome) GrayAt(x, y int) color.Gray

GrayAt implements Gray interface.

func (*Monochrome) Histogram

func (m *Monochrome) Histogram() (histogram [256]int)

Histogram implements Histogramer interface.

func (*Monochrome) Set

func (m *Monochrome) Set(x, y int, c color.Color)

Set implements draw.Image interface.

func (*Monochrome) SetGray

func (m *Monochrome) SetGray(x, y int, g color.Gray)

SetGray implements Gray interface.

func (*Monochrome) Validate

func (m *Monochrome) Validate() error

Validate implements Image interface.

type NRGBA

NRGBA is the interface for all NRGBA images.

type NRGBA interface {
    // NRGBAAt gets the NRGBA color at the coordinates 'x', 'y'.
    NRGBAAt(x, y int) color.NRGBA
    // SetNRGBA sets the NRGBA color at the coordinates 'x', 'y'.
    SetNRGBA(x, y int, c color.NRGBA)
}

type NRGBA16

NRGBA16 implements RGB image with 4 bits.

type NRGBA16 struct {
    ImageBase
}

func (*NRGBA16) At

func (i *NRGBA16) At(x, y int) color.Color

At implements Image interface.

func (*NRGBA16) Base

func (i *NRGBA16) Base() *ImageBase

Base implements Image interface.

func (*NRGBA16) Bounds

func (i *NRGBA16) Bounds() image.Rectangle

Bounds implements image.Image interface.

func (*NRGBA16) ColorAt

func (i *NRGBA16) ColorAt(x, y int) (color.Color, error)

ColorAt implements Image interface.

func (*NRGBA16) ColorModel

func (i *NRGBA16) ColorModel() color.Model

ColorModel implements image.Image interface.

func (*NRGBA16) Copy

func (i *NRGBA16) Copy() Image

Copy implements Image interface.

func (*NRGBA16) NRGBAAt

func (i *NRGBA16) NRGBAAt(x, y int) color.NRGBA

NRGBAAt implements NRGBA interface.

func (*NRGBA16) Set

func (i *NRGBA16) Set(x, y int, c color.Color)

Set implements draw.Image interface.

func (*NRGBA16) SetNRGBA

func (i *NRGBA16) SetNRGBA(x, y int, c color.NRGBA)

SetNRGBA implements NRGBA interface.

func (*NRGBA16) Validate

func (i *NRGBA16) Validate() error

Validate implements Image interface.

type NRGBA32

NRGBA32 implements RGB image with 4 bits.

type NRGBA32 struct {
    ImageBase
}

func (*NRGBA32) At

func (i *NRGBA32) At(x, y int) color.Color

At implements Image interface.

func (*NRGBA32) Base

func (i *NRGBA32) Base() *ImageBase

Base implements Image interface.

func (*NRGBA32) Bounds

func (i *NRGBA32) Bounds() image.Rectangle

Bounds implements image.Image interface.

func (*NRGBA32) ColorAt

func (i *NRGBA32) ColorAt(x, y int) (color.Color, error)

ColorAt implements Image interface.

func (*NRGBA32) ColorModel

func (i *NRGBA32) ColorModel() color.Model

ColorModel implements image.Image interface.

func (*NRGBA32) Copy

func (i *NRGBA32) Copy() Image

Copy implements Image interface.

func (*NRGBA32) NRGBAAt

func (i *NRGBA32) NRGBAAt(x, y int) color.NRGBA

NRGBAAt implements NRGBA implements.

func (*NRGBA32) Set

func (i *NRGBA32) Set(x, y int, c color.Color)

Set implements draw.Image interface.

func (*NRGBA32) SetNRGBA

func (i *NRGBA32) SetNRGBA(x, y int, c color.NRGBA)

SetNRGBA implements NRGBA interface.

func (*NRGBA32) Validate

func (i *NRGBA32) Validate() error

Validate implements Image interface.

type NRGBA64

NRGBA64 implements RGB image with 4 bits.

type NRGBA64 struct {
    ImageBase
}

func (*NRGBA64) At

func (i *NRGBA64) At(x, y int) color.Color

At implements image.Image interface.

func (*NRGBA64) Base

func (i *NRGBA64) Base() *ImageBase

Base implements Image interface.

func (*NRGBA64) Bounds

func (i *NRGBA64) Bounds() image.Rectangle

Bounds implements image.Image interface.

func (*NRGBA64) ColorAt

func (i *NRGBA64) ColorAt(x, y int) (color.Color, error)

ColorAt implements Image interface.

func (*NRGBA64) ColorModel

func (i *NRGBA64) ColorModel() color.Model

ColorModel implements image.Image interface.

func (*NRGBA64) Copy

func (i *NRGBA64) Copy() Image

Copy implements Image interface.

func (*NRGBA64) NRGBA64At

func (i *NRGBA64) NRGBA64At(x, y int) color.NRGBA64

NRGBA64At gets color.NRGBA64 at 'x' and 'y'.

func (*NRGBA64) Set

func (i *NRGBA64) Set(x, y int, c color.Color)

Set implements draw.Image interface.

func (*NRGBA64) SetNRGBA64

func (i *NRGBA64) SetNRGBA64(x, y int, c color.NRGBA64)

SetNRGBA64 sets the 'NRGBA64' color at 'x' and 'y' coordinates.

func (*NRGBA64) Validate

func (i *NRGBA64) Validate() error

Validate implements Image interface.

type RGBA

RGBA is the interface that allows to get and set RGBA images.

type RGBA interface {
    // RGBAAt gets the RGBA color at the coordinates 'x', 'y'.
    RGBAAt(x, y int) color.RGBA
    // SetRGBA sets the RGBA color at the coordinates 'x', 'y'.
    SetRGBA(x, y int, c color.RGBA)
}

type SMasker

SMasker is an interface used to get and check the alpha mask from an image.

type SMasker interface {
    HasAlpha() bool
    GetAlpha() []byte
    MakeAlpha()
}