fb

package
v0.0.0-...-ac0bd47 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2023 License: BSD-3-Clause Imports: 5 Imported by: 4

Documentation

Overview

Package fb provides frame buffer image handling.

Index

Constants

This section is empty.

Variables

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

MonochromeModel is the color model for black and white images.

View Source
var RGB565Model color.Model = color.ModelFunc(rgb565Model)

RGB565Model is the color model for RGB565 images.

View Source
var XRGBModel color.Model = color.ModelFunc(xrgbModel)

XRGBModel is the color model for XRGB images.

Functions

func NewMonochromeWith

func NewMonochromeWith(pix []byte, r image.Rectangle, stride int) (draw.Image, error)

NewMonochromeWith returns a new Monochrome image with the given bounds and stride, backed by the []byte, pix. If stride is zero, a working stride is computed. If the length of pix is less than stride*h, an error is returned.

func NewRGB565With

func NewRGB565With(pix []byte, r image.Rectangle, stride int) (draw.Image, error)

NewRGB565With returns a new RGB565 image with the given bounds, backed by the []byte, pix. If stride is zero, a working stride is computed. If the length of pix is less than stride*h, an error is returned.

func NewXRGBWith

func NewXRGBWith(pix []byte, r image.Rectangle, stride int) (draw.Image, error)

NewXRGBWith returns a new XRGB image with the given bounds, backed by the []byte, pix. If stride is zero, a working stride is computed. If the length of pix is less than stride*h, an error is returned.

Types

type Monochrome

type Monochrome struct {
	// Pix holds the image's pixels, as bit values.
	// The pixel at (x, y) is the x%8^th bit in
	// Pix[(x-Rect.Min.X)/8 + (y-Rect.Min.Y)*Stride].
	Pix []uint8
	// Stride is the Pix stride (in bytes) between
	// vertically adjacent pixels.
	Stride int
	// Rect is the image's bounds.
	Rect image.Rectangle
}

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

func NewMonochrome

func NewMonochrome(r image.Rectangle, stride int) *Monochrome

NewMonochrome returns a new Monochrome image with the given bounds and stride. If stride is zero, a working stride is computed.

func (*Monochrome) At

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

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

func (*Monochrome) Bounds

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

Bounds returns the bounding rectangle for the image.

func (*Monochrome) ColorModel

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

ColorModel returns the monochrome color model.

func (*Monochrome) Set

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

Set sets the color of the pixel at (x, y) to c.

type Pixel

type Pixel bool

Pixel is a black and white monochrome pixel.

const (
	Black Pixel = true
	White Pixel = false
)

func (Pixel) RGBA

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

RGBA returns the RGBA values for the receiver.

type Pixel565

type Pixel565 uint16

Pixel565 is an RGB565 pixel.

func (Pixel565) RGBA

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

RGBA returns the RGBA values for the receiver.

type PixelXRGB

type PixelXRGB struct {
	R, G, B byte
}

PixelXRGB is an XRGB pixel.

func (PixelXRGB) RGBA

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

RGBA returns the RGBA values for the receiver.

type RGB565

type RGB565 struct {
	// Pix holds the image's pixels, as RGB565 values.
	// The Pixel565 at (x, y) is the pair of bytes at
	// Pix[2*(x-Rect.Min.X) + (y-Rect.Min.Y)*Stride].
	// Pixel565 values are encoded little endian in Pix.
	Pix []uint8
	// Stride is the Pix stride (in bytes) between
	// vertically adjacent pixels.
	Stride int
	// Rect is the image's bounds.
	Rect image.Rectangle
}

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

func NewRGB565

func NewRGB565(r image.Rectangle) *RGB565

NewRGB565 returns a new RGB565 image with the given bounds.

func (*RGB565) At

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

At returns the color of the pixel565 at (x, y).

func (*RGB565) Bounds

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

Bounds returns the bounding rectangle for the image.

func (*RGB565) ColorModel

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

ColorModel returns the RGB565 color model.

func (*RGB565) Set

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

Set sets the color of the pixel565 at (x, y) to c.

type XRGB

type XRGB struct {
	// Pix holds the image's pixels, as 32 bit XRGB
	// values stored in little-endian order.
	// The pixel at (x, y) is the four bytes at
	// Pix[4*(x-Rect.Min.X) + (y-Rect.Min.Y)*Stride].
	Pix []uint8
	// Stride is the Pix stride (in bytes) between
	// vertically adjacent pixels.
	Stride int
	// Rect is the image's bounds.
	Rect image.Rectangle
}

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

func NewXRGB

func NewXRGB(r image.Rectangle) *XRGB

NewXRGB returns a new XRGB image with the given bounds.

func (*XRGB) At

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

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

func (*XRGB) Bounds

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

Bounds returns the bounding rectangle for the image.

func (*XRGB) ColorModel

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

ColorModel returns the XRGB color model.

func (*XRGB) Set

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

Set sets the color of the pixel at (x, y) to c.

Jump to

Keyboard shortcuts

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