Documentation
¶
Overview ¶
Package sixel provides sixel graphics format functionality.
Index ¶
- Constants
- Variables
- func ConvertChannel(c uint32) uint32
- func DefaultPalette() color.Palette
- func WriteColor(w io.Writer, pc, pu, px, py, pz int) (int, error)
- func WriteRaster(w io.Writer, pan, pad, ph, pv int) (n int, err error)
- func WriteRepeat(w io.Writer, count int, char byte) (int, error)
- type Color
- type Decoder
- type Encoder
- type Raster
- type Repeat
Constants ¶
const ( LineBreak byte = '-' CarriageReturn byte = '$' RepeatIntroducer byte = '!' ColorIntroducer byte = '#' RasterAttribute byte = '"' )
Sixel control functions.
const ( // MaxColors is the maximum number of colors a sixelPalette can contain. MaxColors int = 256 )
Variables ¶
var ErrInvalidColor = fmt.Errorf("invalid color")
ErrInvalidColor is returned when a Sixel color is invalid.
var ErrInvalidRaster = fmt.Errorf("invalid raster attributes")
ErrInvalidRaster is returned when Raster Attributes are invalid.
var ErrInvalidRepeat = fmt.Errorf("invalid repeat")
ErrInvalidRepeat is returned when a Repeat is invalid.
Functions ¶
func ConvertChannel ¶
ConvertChannel converts a color channel from color.Color 0xffff to 0-100 Sixel RGB format.
func DefaultPalette ¶
DefaultPalette is the default palette used when decoding a Sixel image. It contains the 256 colors defined by the xterm 256-color palette.
func WriteColor ¶
WriteColor writes a Sixel color to a writer. If pu is 0, the rest of the parameters are ignored.
func WriteRaster ¶
WriteRaster writes Raster attributes to a writer. If ph and pv are 0, they are omitted.
Types ¶
type Color ¶
type Color struct {
// Pc is the color number (0-255).
Pc int
// Pu is an optional color system
// - 0: default color map
// - 1: HLS
// - 2: RGB
Pu int
// Color components range from 0-100 for RGB values. For HLS format, the Px
// (Hue) component ranges from 0-360 degrees while L (Lightness) and S
// (Saturation) are 0-100.
Px, Py, Pz int
}
Color represents a Sixel color.
func DecodeColor ¶
DecodeColor decodes a Sixel color from a byte slice. It returns the Color and the number of bytes read.
type Decoder ¶
type Decoder struct{}
Decoder is a Sixel image decoder. It reads Sixel image data from an io.Reader and decodes it into an image.Image.
func (*Decoder) Decode ¶
Decode will parse sixel image data into an image or return an error. Because the sixel image format does not have a predictable size, the end of the sixel image data can only be identified when ST, ESC, or BEL has been read from a reader. In order to avoid reading bytes from a reader one at a time to avoid missing the end, this method simply accepts a byte slice instead of a reader. Callers should read the entire escape sequence and pass the Ps..Ps portion of the sequence to this method.
type Encoder ¶
type Encoder struct{}
Encoder is a Sixel encoder. It encodes an image to Sixel data format.
type Raster ¶
type Raster struct {
Pan, Pad, Ph, Pv int
}
Raster represents Sixel raster attributes.
func DecodeRaster ¶
DecodeRaster decodes a Raster from a byte slice. It returns the Raster and the number of bytes read.
type Repeat ¶
Repeat represents a Sixel repeat introducer.
func DecodeRepeat ¶
DecodeRepeat decodes a Repeat from a byte slice. It returns the Repeat and the number of bytes read.