Documentation ¶
Overview ¶
Package image2bit implements two bit gray scale (white, light gray, dark gray, black) 2D graphics.
It is compatible with package image/draw.
The bit packing format is the same as used by waveshare e-Paper displays such as the 4.2 inch display.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var GrayModel = color.ModelFunc(convert)
GrayModel is the color Model for 2 bit gray scale.
Functions ¶
This section is empty.
Types ¶
type BitPlane ¶
type BitPlane struct { // PixMSB holds the image's most significant bit as a horizontally packed bitmap. PixMSB []byte // PixLSB holds the image's least significant bit as a horizontally packed bitmap. PixLSB []byte // Rect is the image's bounds. Rect image.Rectangle // Stride is the number of pixels on each horizontal line, including padding Stride int }
BitPlane is a 2 bit gray scale image. To match the wire format for waveshare e-Paper the two bits per pixel is stored across two bitmaps. PixMSB contains the most significant bit, PixLSB contains the least significant bit.
White LightGray DarkGray Black PixMSB 1 1 0 0 PixLSB 1 0 1 0
The following example shows the stored data for an 8 pixel wide image, 1 pixel high: PixMSB []byte{0b10100000} PixLSB []byte{0b10000000}
It has a black background, the first pixel is white, and the third pixel LightGray.
func NewBitPlane ¶
NewBitPlane returns an initialized BitPlane instance, all black.
func (*BitPlane) ColorModel ¶
ColorModel implements image.Image.