bitmap

package
v0.0.0-...-a77340a Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ColorModel color.Model = ThresholdColorModel(128)

ColorModel is the default color model for bitmaps.

Functions

func ThresholdColorModel

func ThresholdColorModel(threshold byte) color.Model

ThresholdColorModel returns a color model with the given threshold.

Types

type Device

type Device interface {
	MaxWidth() int
	DPI() float64

	PrintBitmap(img *Image) error
	Feed(lines int) error
}

A Device is an infinitely-tall, 1-bit output device with a maximum width and a DPI.

type Image

type Image struct {
	// contains filtered or unexported fields
}

A Image is a 1-bit image.

func ForDevice

func ForDevice(output Device, img image.Image, dither bool) *Image

ForDevice converts the input image to a device-appropriate bitmap, downscaling and dithering as necessary.

func New

func New(r image.Rectangle) *Image

New creates a new Image with the given bounds.

func NewThreshold

func NewThreshold(r image.Rectangle, threshold byte) *Image

NewWithThreshold creates a new Image with the given bounds and threshold.

func (*Image) At

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

At returns the color of the pixel at (x, y). At(Bounds().Min.X, Bounds().Min.Y) returns the upper-left pixel of the grid. At(Bounds().Max.X-1, Bounds().Max.Y-1) returns the lower-right one.

Set bits return color.White; unset bits return color.Black.

func (*Image) BitAt

func (b *Image) BitAt(x, y int) bool

BitAt returns true if the bit at (x, y) is set and false if it is not.

func (*Image) Bounds

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

Bounds returns the domain for which At can return non-zero color. The bounds do not necessarily contain the point (0, 0).

func (*Image) ColorModel

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

ColorModel returns the Image's color model.

func (*Image) Set

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

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

func (*Image) SetBit

func (b *Image) SetBit(x, y int, v bool)

SetBit sets or clears the bit at (x, y).

Jump to

Keyboard shortcuts

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