bitmap

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: MIT Imports: 3 Imported by: 3

Documentation

Overview

Package bitmap support binary image format.

Index

Constants

This section is empty.

Variables

View Source
var ColorModel color.Model = color.ModelFunc(binaryModel)

Functions

This section is empty.

Types

type Color

type Color bool

Color is binary color.

const (
	// White is white color.
	White Color = false

	// Black is black color.
	Black Color = true
)

func (Color) RGBA

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

RGBA implements image/color.Color.

type Image

type Image struct {
	// Pix holds the image's pixels, in binary format.
	// Each bit represents a pixel: 1 is black, 0 is white.
	// The order of the pixels is left to right.
	// The pixel at (x, y) starts at Pix[(y-Rect.Min.Y)*Stride + (x-Rect.Min.X)*2].
	Pix []uint8

	// Stride is the Pix stride (in bytes) between vertically adjacent pixels.
	Stride int

	// Rect is the image's bounds.
	Rect image.Rectangle
}

Image is a binary image.

func New

func New(r image.Rectangle) *Image

New returns a new binary image with the bounds r.

func (*Image) At

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

At implements image.Image.

func (*Image) BinaryAt

func (img *Image) BinaryAt(x, y int) Color

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

func (*Image) Bounds

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

Bounds implements image.Image.

func (*Image) ColorModel

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

ColorModel implements image.Image.

func (*Image) Set

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

Set implements draw.Image.

func (*Image) SetBinary

func (img *Image) SetBinary(x, y int, c Color)

SetBinary 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