pixel

package
v0.0.0-...-119448c Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2018 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StripLinearExp

func StripLinearExp(val byte) byte

StripLinearExp returns the linear expansion factor for the given value.

Types

type Buffer

type Buffer struct {
	// Layout is the buffer layout to use.
	//
	// Adjusting this value will invalidate the current buffered data. The user
	// must call Reset afterwards.
	Layout BufferLayout
	// contains filtered or unexported fields
}

Buffer represents the wire format for a series of consecutive pixels. It is used for minimal-copy pixel processing.

func (*Buffer) AntiLog

func (pb *Buffer) AntiLog()

AntiLog performs an antilog transform on every pixel in the buffer. This is more efficient than calling AntiLog on each individual pixel.

func (*Buffer) Bytes

func (pb *Buffer) Bytes() []byte

Bytes returns the raw bytes for this buffer.

func (*Buffer) CloneFrom

func (pb *Buffer) CloneFrom(other *Buffer)

CloneFrom clones the state of other efficiently.

func (*Buffer) CloneFromWithLen

func (pb *Buffer) CloneFromWithLen(other *Buffer, count int)

CloneFromWithLen clones pb from the pixels in other. pb will have count pixels. If other has additional pixels, they will be discarded during the clone. If other has fewer pixels, pb's remainder will be left uninitialised (black).

func (*Buffer) CopyPixelValuesFrom

func (pb *Buffer) CopyPixelValuesFrom(other *Buffer)

CopyPixelValuesFrom tries to set pb's pixel values to match those in other.

If pb's flags and size align with other, this will be a fast buffer copy. Otherwise, as many pixels as possible will be copied from other one-by-one.

In either case, pb will not have its flags or size changed.

func (*Buffer) Len

func (pb *Buffer) Len() int

Len returns the number of pixels allocated in pb.

func (*Buffer) Pixel

func (pb *Buffer) Pixel(i int) (p P)

Pixel returns the pixel data for the Pixel at index i.

If i is out of bounds, Pixel will return a zero value.

func (*Buffer) ReadFrom

func (pb *Buffer) ReadFrom(r *byteslicereader.R, size int) error

ReadFrom reads a Buffer with size pixels from the supplied byte slice reader.

The Buffer's underlying data will be a pointer into that byte slice reader's buffer, and pb expects to take ownership over that section of the buffer.

func (*Buffer) Reset

func (pb *Buffer) Reset(size int)

Reset clears the buffer and allocates room for size pixels.

If the underlying buffer is already >= this size, it will be reused; otherwise, a new buffer will be allocated.

func (*Buffer) SetPixel

func (pb *Buffer) SetPixel(i int, p P)

SetPixel sets the pixel value at index i.

If i is out of bounds, SetPixel will do nothing.

func (*Buffer) SetPixels

func (pb *Buffer) SetPixels(pixels ...P)

SetPixels sets the Buffer's content to the set of pixels provided.

func (*Buffer) UseBytes

func (pb *Buffer) UseBytes(buf []byte)

UseBytes loads buf directly into this Buffer. This creates a functional Buffer with no copying.

Note that buf may be retained and used by pb indefnitely, and should not be reused while pb is active. Loading a new buffer using UseBytes will cause pb to stop using buf.

type BufferLayout

type BufferLayout int

BufferLayout is the layout of a pixel buffer.

const (
	// BufferRGB is a BufferLayout specifying a series of contiguous (R, G, B)
	// pixel value bytes.
	BufferRGB BufferLayout = iota
	// BufferRGBOW is a BufferLayout specifying a series of contiguous
	// (R, G, B, OOO, WWW) pixel value bytes. The O and W bytes are each three
	// bytes of the same value.
	BufferRGBOW
)

type P

type P struct {
	Red   uint8
	Green uint8
	Blue  uint8

	// Note that Orange and White take three bytes in the protocol, despite the
	// fact that they can only hold a single byte value.
	//
	// These may not be populated if the strip is not an RGBOW strip.
	Orange uint8
	White  uint8
}

P is the state of a single pixel.

Depending on the strip that P belongs to, Orange and White may be ignored.

func (*P) AntiLog

func (p *P) AntiLog() P

AntiLog returns a new Pixel that has been shifted against the pixelLinearExp luminescence shift table.

This shift can increase the quality of video rendering.

func (*P) String

func (p *P) String() string

Jump to

Keyboard shortcuts

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