format

package
v0.0.0-...-474862e Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2024 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ARGB8888 formatARGB8888
	XRGB8888 formatXRGB8888
)

Various predefined Formats.

Functions

This section is empty.

Types

type Color

type Color struct {
	Format Format

	// Data contains the pixel data for the color. Only some bytes of
	// the array are used, dependant on the return value of Format.Size.
	Data [8]byte
}

Color implements color.Color using a Format.

func (*Color) RGBA

func (c *Color) RGBA() (r, g, b, a uint32)

func (*Color) Slice

func (c *Color) Slice() []byte

Slice returns a slice of Data correctly sized for the color's format.

type Format

type Format interface {
	// Size returns the number of bytes per pixel.
	Size() int

	// Read reads raw pixel data and converts it to alpha-premultiplied
	// RGBA values, similar to color.Color's RGBA method.
	Read([]byte) (r, g, b, a uint32)

	// Write writes alpha-premultiplied RGBA values into buf.
	Write(buf []byte, r, g, b, a uint32)
}

Format is a pixel format for a FormatImage and related types. This package contains several predefined formats, such as ARGB8888.

type Image

type Image struct {
	Format Format
	Rect   image.Rectangle
	Pix    []byte
}

Image is an image with a color format defined by Format.

func (*Image) At

func (img *Image) At(x, y int) color.Color

func (*Image) Bounds

func (img *Image) Bounds() image.Rectangle

func (*Image) ColorModel

func (img *Image) ColorModel() color.Model

func (*Image) PixOffset

func (img *Image) PixOffset(x, y int) int

func (*Image) Set

func (img *Image) Set(x, y int, c color.Color)

func (*Image) Stride

func (img *Image) Stride() int

type Model

type Model struct {
	Format Format
}

Model implements color.Model using a Format.

func (Model) Convert

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

Jump to

Keyboard shortcuts

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