Skip to main content

Interface IPixelBuffer

IPixelBuffer provides a standard interface for representing the display state of a device capable of displaying pixels. It specifies methods for performing common primitive operations on a buffer of pixel data.

Conceptually, implementing classes should:

  1. Specify a bit depth for pixels
  2. Specify a color mode
  3. Preserve the display state as a byte[] in the PixelBuffer
  4. Optimize primitive drawing methods for the bit depth of pixels
  5. Be abstracted/decoupled from a specific device driver
Assembly: Meadow.Foundation.dll
View Source
Declaration
public interface IPixelBuffer

Properties

Width

The width of the pixel buffer

View Source
Declaration
int Width { get; }

Height

The height of the pixel buffer

View Source
Declaration
int Height { get; }

ColorMode

The ColorMode of the pixel buffer

View Source
Declaration
ColorMode ColorMode { get; }

BitDepth

The BitDepth of the chosen ColorMode.

View Source
Declaration
int BitDepth { get; }

ByteCount

The number of bytes in this pixel buffer

View Source
Declaration
int ByteCount { get; }

Buffer

The byte array that holds all pixel data

View Source
Declaration
byte[] Buffer { get; }

Methods

SetPixel(int, int, Color)

Set the color of the pixel at the provided coordinates

View Source
Declaration
void SetPixel(int x, int y, Color color)
Parameters
TypeNameDescription
System.Int32xX coordinate of the pixel: 0,0 at top left
System.Int32yY coordinate of the pixel: 0,0 at top left
Meadow.ColorcolorThe pixel color

GetPixel(int, int)

Get the color of a pixel - may be scaled based on buffer color depth

View Source
Declaration
Color GetPixel(int x, int y)
Returns

Meadow.Color

Parameters
TypeNameDescription
System.Int32xX coordinate of the pixel: 0,0 at top left
System.Int32yY coordinate of the pixel: 0,0 at top left

InvertPixel(int, int)

Invert the color of a pixel at the provided location

View Source
Declaration
void InvertPixel(int x, int y)
Parameters
TypeNameDescription
System.Int32xThe X coord to invert
System.Int32yThe Y coord to invert

WriteBuffer(int, int, IPixelBuffer)

Writes another pixel buffer into this buffer.

View Source
Declaration
void WriteBuffer(int originX, int originY, IPixelBuffer buffer)
Parameters
TypeNameDescription
System.Int32originXThe X origin to start writing
System.Int32originYThe Y origin to start writing
Meadow.Foundation.Graphics.Buffers.IPixelBufferbufferThe buffer to write into this buffer

Fill(Color)

Fills the buffer with the provided color

View Source
Declaration
void Fill(Color color)
Parameters
TypeNameDescription
Meadow.ColorcolorThe color to fill

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

Fills part of the buffer with the provided color

View Source
Declaration
void Fill(int originX, int originY, int width, int height, Color color)
Parameters
TypeNameDescription
System.Int32originXThe X coord to start filling
System.Int32originYThe Y coord to start filling
System.Int32widthThe width to fill
System.Int32heightThe height to fill
Meadow.ColorcolorThe color to fill

Clear()

Clears the buffer (writes 0s to the byte array)

View Source
Declaration
void Clear()

Clear(int, int, int, int)

Clears a region of the buffer (writes 0s to the byte array)

View Source
Declaration
void Clear(int originX, int originY, int width, int height)
Parameters
TypeNameDescription
System.Int32originXThe X coord to start
System.Int32originYThe Y coord to start
System.Int32widthThe width of the region to clear
System.Int32heightThe height of the region to clear