image

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Black uint8 = 0
	White uint8 = 255
)

Monochrome color is either a black or white. 0 = White 255 = Black

Variables

View Source
var MonochromeModel color.Model = color.ModelFunc(monochromeModel)

MonochromeModel for the color of black and white type.

Functions

func ReadFile added in v0.2.0

func ReadFile(path string) (img.Image, error)

ReadFile reads image file format from given path and decode it to Go standard image format

func WriteFile added in v0.2.0

func WriteFile(_img img.Image, path, filename string) error

WriteFile writes image to local file directory of given path currently generates image file in .png extension format

Types

type CropRectangle added in v0.7.0

type CropRectangle interface {
	SubImage(r img.Rectangle) img.Image
}

type Image

type Image struct {
	Data img.Image
}

Image is a data struct which embeds Go standard image library.

func New

func New(img img.Image) *Image

New returns a new Image struct.

func (*Image) Base64

func (p *Image) Base64() (string, error)

Base64 encodes an image that has been decoded previously through New function. The string returned is a base64 format of the given image.

func (*Image) Bytes

func (p *Image) Bytes() ([]byte, error)

Bytes returns an encoded data of the given image in bytes format.

func (*Image) Crop added in v0.7.0

func (p *Image) Crop(minX, minY, maxX, maxY int) img.Image

func (*Image) Monochrome added in v0.4.0

func (p *Image) Monochrome(threshold uint8, inverse bool) *Monochrome

Monochrome converts registered image from New function and returns Monochrome type image.

type Monochrome added in v0.2.0

type Monochrome struct {
	// Pix holds the image's pixels, as gray values. The pixel at
	// (x, y) starts at Pix[(y-Rect.Min.Y)*Stride + (x-Rect.Min.X)*1].
	Pix []uint8
	// Stride is the Pix stride (in bytes) between vertically adjacent pixels.
	Stride int
	// Rect is the image's bounds.
	Rect img.Rectangle
	// Threshold is the value which determines black / white pixel
	Threshold uint8
	// contains filtered or unexported fields
}

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

func NewMonochrome added in v0.2.0

func NewMonochrome(r img.Rectangle, threshold uint8) *Monochrome

NewMonochrome returns a new Monochrome image with the given bounds.

func (*Monochrome) At added in v0.2.0

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

At returns pixel color of the image at (x,y) coordinate point.

func (*Monochrome) Bounds added in v0.2.0

func (p *Monochrome) Bounds() img.Rectangle

Bounds returns rectangle boundary of the image.

func (*Monochrome) ColorModel added in v0.2.0

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

ColorModel returns the MonochromeModel color type.

func (*Monochrome) Crop added in v0.7.0

func (p *Monochrome) Crop(minX, minY, maxX, maxY int) img.Image

func (*Monochrome) Histogram added in v0.3.0

func (p *Monochrome) Histogram(vertical bool) []uint16

Histogram returns array of data from registered Monochrome image type vertical = false, horizontal axis profile vertical = true, vertical axis profile

func (*Monochrome) Inverse added in v0.9.0

func (p *Monochrome) Inverse()

Inverse set [inverse] parameter to true

func (*Monochrome) PixOffset added in v0.2.0

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

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

func (*Monochrome) Set added in v0.2.0

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

Set determines black or white pixel color at (x,y) coordinate point by comparing given MonochromeColor model value to defined threshold value.

func (*Monochrome) SubImage added in v0.7.1

func (p *Monochrome) SubImage(r img.Rectangle) img.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 MonochromeColor added in v0.2.0

type MonochromeColor struct {
	Y uint8
}

MonochromeColor represents a 1-bit color.

func (MonochromeColor) RGBA added in v0.2.0

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

RGBA returns the RGBA values of MonochromeColor type.

Jump to

Keyboard shortcuts

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