Characteristic Locus
Inheritance object > PixelBufferBase > Buffer1bpp > BufferGray4 > BufferGray8 > BufferIndexed4 > BufferRgb332 > BufferRgb444 > BufferRgb565 > BufferRgb888 > BufferRgba8888
Implements IPixelBuffer IDisposable
Inherited Members object.Equals(object) object.Equals(object, object) object.GetHashCode() object.GetType() object.MemberwiseClone() object.ReferenceEquals(object, object) object.ToString()
Namespace Meadow.Foundation.Graphics.Buffers
Assembly MicroGraphics.dll

Syntax

public abstract class PixelBufferBase : IPixelBuffer, IDisposable

Constructors

PixelBufferBase()

Create a new PixelBufferBase object

Declaration
public PixelBufferBase()

PixelBufferBase(int, int)

Create a new PixelBufferBase object

Declaration
public PixelBufferBase(int width, int height)

Parameters

Type Name Description
int width

Width in pixels

int height

Height in pixels

PixelBufferBase(int, int, byte[])

Create a new PixelBufferBase object

Declaration
public PixelBufferBase(int width, int height, byte[] buffer)

Parameters

Type Name Description
int width

Width in pixels

int height

Height in pixels

byte[] buffer

The buffer to hold the pixel data

Properties

BitDepth

Bit depth of display as an integer

Declaration
public int BitDepth { get; }

Property Value

Type Description
int

Buffer

The buffer that holds the pixel data The packing structure in buffer-specific

Declaration
public byte[] Buffer { get; protected set; }

Property Value

Type Description
byte[]

ByteCount

Number of bytes in buffer

Declaration
public int ByteCount { get; }

Property Value

Type Description
int

ColorMode

Color mode of the buffer

Declaration
public virtual ColorMode ColorMode { get; protected set; }

Property Value

Type Description
ColorMode

Height

Height of buffer in pixels

Declaration
public int Height { get; protected set; }

Property Value

Type Description
int

Width

Width of buffer in pixels

Declaration
public int Width { get; protected set; }

Property Value

Type Description
int

Methods

Clear()

Clear the array that stores the pixel buffer

Declaration
public virtual void Clear()

ConvertPixelBuffer<T>()

Create a new pixel buffer and copy/convert pixel data from existing buffer

Declaration
public T ConvertPixelBuffer<T>() where T : PixelBufferBase, new()

Returns

Type Description
T

A pixel buffer derived from PixelBufferBase

Type Parameters

Name Description
T

The buffer type to convert to

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Declaration
public void Dispose()

Dispose(bool)

Dispose of the object

Declaration
protected virtual void Dispose(bool disposing)

Parameters

Type Name Description
bool disposing

Is disposing

Fill(Color)

Fill the entire pixel buffer with a color

Declaration
public abstract void Fill(Color color)

Parameters

Type Name Description
Color color

Fill color

Fill(int, int, int, int, Color)

Fill a region of the pixel buffer with a color

Declaration
public abstract void Fill(int originX, int originY, int width, int height, Color color)

Parameters

Type Name Description
int originX

X pixel to start fill

int originY

Y pixel to start fill

int width

Width to fill

int height

height to fill

Color color

Fill color

GetColorDistance(Color, Color)

Calculate the uncorrected distance between two colors using bytes for red, green, blue

Declaration
public double GetColorDistance(Color color1, Color color2)

Parameters

Type Name Description
Color color1
Color color2

Returns

Type Description
double

The distance as a double

GetPixel(int, int)

Get pixel at location

Declaration
public abstract Color GetPixel(int x, int y)

Parameters

Type Name Description
int x

X pixel location

int y

Y pixel location

Returns

Type Description
Color

InitializeBuffer(bool)

Initialize the pixel buffer based on the current width, height and color depth

Declaration
public void InitializeBuffer(bool replaceIfExists = false)

Parameters

Type Name Description
bool replaceIfExists

If true, will recreates the buffer if it already exists

InvertPixel(int, int)

Invert pixel color at location

Declaration
public abstract void InvertPixel(int x, int y)

Parameters

Type Name Description
int x

X pixel location

int y

Y pixel location

RotateAndConvert<T>(RotationType)

Create a new buffer from the existing buffer with a new rotation

Declaration
public T RotateAndConvert<T>(RotationType rotation) where T : PixelBufferBase, new()

Parameters

Type Name Description
RotationType rotation

Rotation

Returns

Type Description
T

The new buffer

Type Parameters

Name Description
T

Buffer type

ScaleUp<T>(int)

Create a new buffer scaled up from the existing buffer

Declaration
public T ScaleUp<T>(int scaleFactor) where T : PixelBufferBase, new()

Parameters

Type Name Description
int scaleFactor

Integer scale ratio

Returns

Type Description
T

The new buffer

Type Parameters

Name Description
T

Buffer type

SetPixel(int, int, Color)

Set pixel at location to a color

Declaration
public abstract void SetPixel(int x, int y, Color color)

Parameters

Type Name Description
int x

X pixel location

int y

Y pixel location

Color color

Pixel color

WriteBuffer(int, int, IPixelBuffer)

Default way to write a buffer into this buffer.

This is very slow and should be avoided if possible. It loops through every pixel. If the buffer bit depths match there should be faster ways to write using Array.Copy.

Declaration
public virtual void WriteBuffer(int originX, int originY, IPixelBuffer buffer)

Parameters

Type Name Description
int originX

The X coord to start writing

int originY

The Y coord to start writing

IPixelBuffer buffer

The buffer to copy into this buffer

WriteBufferSlow(int, int, IPixelBuffer)

A slow buffer write operation that writes pixel-by-pixel using the Color struct to scale color based on bit depth.

This method can handle buffers with mismatched bit depths.

Declaration
protected void WriteBufferSlow(int originX, int originY, IPixelBuffer buffer)

Parameters

Type Name Description
int originX

The X coord to start writing the buffer

int originY

The Y coord to start writing the buffer

IPixelBuffer buffer

The buffer to write