bi

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 20, 2021 License: MIT Imports: 10 Imported by: 0

README

Bad Image (.bi)

bi is a library for the BI image format. The BI format encodes images so that they are essentially 2D matrices of plaintext color names such as those found in the CSS Color Module Level 4 or hex quadruplets like #FF69B4FF. There is also support for third party color models. Nice.

For example, a valid 2x2 pixel image is:

bi,v1
red,green
blue,white

Examples


Before BI encoding.

Before BI encoding.


After BI encoding using the CSS Color Module Level 4 color model. And re-encoded as PNG obvs.

After BI encoding using the CSS Color Module Level 4 color model. And re-encoded as PNG obvs.


License

This project is licensed under the MIT license.

Documentation

Index

Constants

View Source
const (
	// Extension is the extension for Extension image files.
	Extension = ".bi"
	// MagicNumber is the magic number at the start of BI files.
	MagicNumber = "bi"
)

Variables

This section is empty.

Functions

func Decode

func Decode(r io.Reader) (m image.Image, err error)

Decode reads a BI image from Reader r and returns it as an Image m.

func DecodeConfig

func DecodeConfig(r io.Reader) (c image.Config, err error)

DecodeConfig decodes the Model and dimensions of a BI image from Reader r.

func Encode

func Encode(w io.Writer, m image.Image, mod Model) error

Encode encodes the Image m to the Writer w in BI format using the Model mod. This is usually a very lossy process.

func RegisterModel added in v1.2.0

func RegisterModel(mod Model)

RegisterModel registers a Model for use by Decode.

Types

type Model added in v1.1.0

type Model interface {
	ID() string
	color.Model
	ColorToName(c color.Color) string
	NameToColor(name string) (c color.Color, ok bool)
}

Model can convert any Color to one from its own color model, and can convert a color to the name of the color, and can convert from a name of a color to the color.

var Hex Model = hex{}

Hex is a Model for hex quadruplet color codes in the format #FF69B4FF, including alpha.

https://css-tricks.com/8-digit-hex-codes/

var Standard Model = standard{}

Standard is a Model for CSS Color Module Level 4.

https://www.w3.org/TR/css-color-4/#named-colors

Jump to

Keyboard shortcuts

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