image1bit

package
v3.6.8+incompatible Latest Latest
Warning

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

Go to latest
Published: May 24, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package image1bit implements black and white (1 bit per pixel) 2D graphics.

It is compatible with package image/draw.

VerticalLSB is the only bit packing implemented as it is used by the ssd1306. Others would be VerticalMSB, HorizontalLSB and HorizontalMSB.

Index

Constants

This section is empty.

Variables

View Source
var BitModel = color.ModelFunc(convert)

BitModel is the color Model for 1 bit color.

Functions

This section is empty.

Types

type Bit

type Bit bool

Bit implements a 1 bit color.

const (
	On  Bit = true
	Off Bit = false
)

Possible bitness.

func (Bit) RGBA

func (b Bit) RGBA() (uint32, uint32, uint32, uint32)

RGBA returns either all white or all black.

Technically the monochrome display could be colored but this information is unavailable here. To use a colored display, use the 1 bit image as a mask for a color.

func (Bit) String

func (b Bit) String() string

type VerticalLSB

type VerticalLSB struct {
	// Pix holds the image's pixels, as vertically LSB-first packed bitmap. It
	// can be passed directly to ssd1306.Dev.Write()
	Pix []byte
	// Stride is the Pix stride (in bytes) between vertically adjacent 8 pixels
	// horizontal bands.
	Stride int
	// Rect is the image's bounds.
	Rect image.Rectangle
}

VerticalLSB is a 1 bit (black and white) image.

Each byte is 8 vertical pixels. Each stride is an horizontal band of 8 pixels high with LSB first. So the first byte represent the following pixels, with lowest bit being the top left pixel.

0 x x x x x x x
1 x x x x x x x
2 x x x x x x x
3 x x x x x x x
4 x x x x x x x
5 x x x x x x x
6 x x x x x x x
7 x x x x x x x

It is designed specifically to work with SSD1306 OLED display controler.

func NewVerticalLSB

func NewVerticalLSB(r image.Rectangle) *VerticalLSB

NewVerticalLSB returns an initialized VerticalLSB instance.

func (*VerticalLSB) At

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

At implements image.Image.

func (*VerticalLSB) BitAt

func (i *VerticalLSB) BitAt(x, y int) Bit

BitAt is the optimized version of At().

func (*VerticalLSB) Bounds

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

Bounds implements image.Image.

func (*VerticalLSB) ColorModel

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

ColorModel implements image.Image.

func (*VerticalLSB) Opaque

func (i *VerticalLSB) Opaque() bool

Opaque scans the entire image and reports whether it is fully opaque.

func (*VerticalLSB) PixOffset

func (i *VerticalLSB) PixOffset(x, y int) (int, byte)

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

func (*VerticalLSB) Set

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

Set implements draw.Image

func (*VerticalLSB) SetBit

func (i *VerticalLSB) SetBit(x, y int, b Bit)

SetBit is the optimized version of Set().

Jump to

Keyboard shortcuts

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