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 ¶
- Variables
- type Bit
- type VerticalLSB
- func (i *VerticalLSB) At(x, y int) color.Color
- func (i *VerticalLSB) BitAt(x, y int) Bit
- func (i *VerticalLSB) Bounds() image.Rectangle
- func (i *VerticalLSB) ColorModel() color.Model
- func (i *VerticalLSB) Opaque() bool
- func (i *VerticalLSB) PixOffset(x, y int) (int, byte)
- func (i *VerticalLSB) Set(x, y int, c color.Color)
- func (i *VerticalLSB) SetBit(x, y int, b Bit)
Constants ¶
This section is empty.
Variables ¶
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.
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 a horizontal band of 8 pixels high with LSB first. So the first byte represents 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 controller.
func NewVerticalLSB ¶
func NewVerticalLSB(r image.Rectangle) *VerticalLSB
NewVerticalLSB returns an initialized VerticalLSB instance.
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().