dither

package
v0.0.0-...-97953f7 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BlackAndWhitePalette

func BlackAndWhitePalette(c color.Color) color.Color

BlackAndWhitePalette converts colors to either black or white. RGB values are converted into grayscale with: gray = (r + g + b) / 3 If gray is under 0x0FFF it is converted to black and otherwise to white.

func Burkes

func Burkes(x, y int, img *image.RGBA, err RGBAVec)

Burkes applies Burkes dithering to image. Should not be called directly and should be rather passed Dither function.

func Dither

func Dither(img image.Image, algo Algo, find ColorFinder) image.Image

Dither applies given dithering algorithm to the image. Quantinization can be controlled by fjnd callback that should return closet color available.

func FloydSteinberg

func FloydSteinberg(x, y int, img *image.RGBA, err RGBAVec)

FloydSteinberg applies Floyd-Steinber dithering to image. Should not be called directly and should be rather passed Dither function.

func Plan9Palette

func Plan9Palette(c color.Color) color.Color

Plan9Palette converts colors to the ones found in palette.Plan9

func WebSafePalette

func WebSafePalette(c color.Color) color.Color

WebSafePalette converts colors to the ones found in palette.WebSafe

Types

type Algo

type Algo func(int, int, *image.RGBA, RGBAVec)

Algo is callback function type for Dither function that applies the actual dithering.

type ColorFinder

type ColorFinder func(c color.Color) color.Color

ColorFinder specifies who to transform given color to suit the palette

type RGBAVec

type RGBAVec struct {
	// TODO: int32 or int would be probably enough
	R int64
	G int64
	B int64
	A int64
}

RGBAVec is container for single pixel values. Values are stored as int64 to prevent underflow and overflow.

Jump to

Keyboard shortcuts

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