Table of Contents

Class FrameBuffer2BitPerPixel

Namespace
Iot.Device.EPaper.Buffers
Assembly
Iot.Device.ePaper.dll

A display frame buffer implementation for tri-color displays with a separate buffer for the 3rd color. Wraps 2 FrameBuffer1BitPerPixel internally.

public sealed class FrameBuffer2BitPerPixel : IFrameBuffer
Inheritance
FrameBuffer2BitPerPixel
Implements

Constructors

FrameBuffer2BitPerPixel(int, int)

Initializes a new instance of the FrameBuffer2BitPerPixel class.

public FrameBuffer2BitPerPixel(int height, int width)

Parameters

height int

The height of the frame to manage.

width int

The width of the frame to manage.

Properties

BitDepth

Gets the bit depth of the frame.

public int BitDepth { get; }

Property Value

int

BlackBuffer

Gets a buffer representing the Black/White frame.

public FrameBuffer1BitPerPixel BlackBuffer { get; }

Property Value

FrameBuffer1BitPerPixel

Buffer

Gets the internal buffer representing this frame.

public byte[] Buffer { get; }

Property Value

byte[]

Exceptions

InvalidOperationException

Unified buffer is not available. Use BlackBuffer and ColorBuffer instead.

BufferByteCount

Gets the total number of bytes that the current buffer is made of.

public int BufferByteCount { get; }

Property Value

int

Remarks

For this implementation of IFrameBuffer, this number represents the total number of bytes making up BlackBuffer and ColorBuffer

ColorBuffer

Gets a buffer representing the color frame.

public FrameBuffer1BitPerPixel ColorBuffer { get; }

Property Value

FrameBuffer1BitPerPixel

ColorFormat

Gets the color format used across this frame buffer.

public ColorFormat ColorFormat { get; }

Property Value

ColorFormat

CurrentFramePage

Gets or sets the current frame page index which this frame instance is covering.

public int CurrentFramePage { get; set; }

Property Value

int

Height

Gets the width of the buffer in pixel.

public int Height { get; }

Property Value

int

this[Point]

Gets or sets a byte from the Buffer using the specified point.

public byte this[Point point] { get; set; }

Parameters

point Point

The point to get the byte containing the pixel.

Property Value

byte

A byte that contains the pixel specified by the point.

this[int]

Gets or sets a byte from the Buffer using the specified index value.

public byte this[int index] { get; set; }

Parameters

index int

The index of the byte to get.

Property Value

byte

A byte from Buffer

StartPoint

Gets or sets the position from which this frame's area starts.

public Point StartPoint { get; set; }

Property Value

Point

Width

Gets the height of the buffer in pixel.

public int Width { get; }

Property Value

int

Methods

Clear()

Resets the current frame buffer to its default starting values (all pixels set to 0).

public void Clear()

Clear(Color)

Resets the current frame buffer to with its default starting values set to the specified color.

public void Clear(Color color)

Parameters

color Color

The color to use as a default value when clearing the frame buffer.

Fill(Color)

Fill the entire frame buffer using the specified color.

public void Fill(Color color)

Parameters

color Color

The color to fill the frame with.

Fill(Point, int, int, Color)

Fill the specific portion of the frame buffer with the specified color.

public void Fill(Point start, int width, int height, Color color)

Parameters

start Point

The starting position.

width int

The width of the area.

height int

The height of the area.

color Color

The color value to use.

GetPixel(Point)

Gets the pixel at the specified position.

public Color GetPixel(Point point)

Parameters

point Point

The position to get the pixel from.

Returns

Color

Color representing the specified pixel.

Remarks

This method is not implemented for this class as it is not possible to convert a byte from BlackBuffer and ColorBuffer into a Color struct. We don't know what color ColorBuffer represents in the actual display hardware.

Exceptions

InvalidOperationException

IsBlackPixel(Point)

Checks if the specified pixel is set to 0 in the BlackBuffer and 0 in the ColorBuffer

public bool IsBlackPixel(Point point)

Parameters

point Point

The pixel position.

Returns

bool

True if pixel is black color, otherwise; false.

IsColoredPixel(Point)

Checks if the specified pixel is set to 0 in the BlackBuffer and 1 in the ColorBuffer

public bool IsColoredPixel(Point point)

Parameters

point Point

The pixel position.

Returns

bool

True if pixel is a color other than black/white, otherwise; false.

Remarks

Make sure to consider the result of IsBlackPixel(Point) as this is not enough on its own.

IsPointWithinFrameBuffer(Point)

Checks if the specified point falls within the area this buffer is covering.

public bool IsPointWithinFrameBuffer(Point point)

Parameters

point Point

The point to check.

Returns

bool

True if the point is within this frame's area, otherwise; false.

IsRangeWithinFrameBuffer(Point, Point)

Checks if the specified range of points is within the current frame buffer.

public bool IsRangeWithinFrameBuffer(Point start, Point end)

Parameters

start Point

The starting point of the range.

end Point

The end point of the range.

Returns

bool

True if the range is within this frame's area, otherwise; false.

IsWhitePixel(Point)

Checks if the specified pixel is set to 1 in the BlackBuffer and 0 in the ColorBuffer

public bool IsWhitePixel(Point point)

Parameters

point Point

The pixel position.

Returns

bool

True if pixel is white color, otherwise; false.

Remarks

Make sure to consider the result of IsColoredPixel(Point) as this is not enough on its own.

SetPixel(Point, Color)

Sets the value of the pixel at the specified position.

public void SetPixel(Point point, Color pixelColor)

Parameters

point Point

The position to set the pixel.

pixelColor Color

The pixel color value to use.

WriteBuffer(IFrameBuffer)

Copies the entire specified IFrameBuffer into the current frame buffer.

public void WriteBuffer(IFrameBuffer buffer)

Parameters

buffer IFrameBuffer

The IFrameBuffer to copy from.

WriteBuffer(IFrameBuffer, Point)

Copies the specified IFrameBuffer into the current frame buffer.

public void WriteBuffer(IFrameBuffer buffer, Point destinationStart)

Parameters

buffer IFrameBuffer

The IFrameBuffer to copy from.

destinationStart Point

The start point to begin writing to.

WriteBuffer(IFrameBuffer, Point, Point, Point)

Copies the specified IFrameBuffer into the current frame buffer.

public void WriteBuffer(IFrameBuffer buffer, Point start, Point end, Point destinationStart)

Parameters

buffer IFrameBuffer

The IFrameBuffer to copy from.

start Point

The start position to copy from.

end Point

The point at which copying from the buffer will stop.

destinationStart Point

The start point to begin writing to.