Class FrameBufferBase
Base implementation for a frame buffer class.
public abstract class FrameBufferBase : IFrameBuffer
- Inheritance
-
FrameBufferBase
- Implements
- Derived
Constructors
FrameBufferBase(int, int)
Initializes a new instance of the FrameBufferBase class.
protected FrameBufferBase(int height, int width)
Parameters
FrameBufferBase(int, int, byte[])
Initializes a new instance of the FrameBufferBase class by copying the specified buffer.
protected FrameBufferBase(int height, int width, byte[] buffer)
Parameters
heightintThe height of the frame to manage.
widthintThe width of the frame to manage.
bufferbyte[]The starting frame buffer.
Exceptions
- ArgumentException
Length mismatch between the provided buffer and the specified width and height.
Properties
BitDepth
Gets the bit depth of the frame.
public virtual int BitDepth { get; }
Property Value
Buffer
Gets the internal buffer representing this frame.
public virtual byte[] Buffer { get; }
Property Value
- byte[]
BufferByteCount
Gets the total number of bytes that the current buffer is made of.
public virtual int BufferByteCount { get; }
Property Value
ColorFormat
Gets the color format used across this frame buffer.
public abstract ColorFormat ColorFormat { get; }
Property Value
CurrentFramePage
Gets or sets the current frame page index which this frame instance is covering.
public virtual int CurrentFramePage { get; set; }
Property Value
Height
Gets the width of the buffer in pixel.
public int Height { get; }
Property Value
this[Point]
Gets or sets a byte from the Buffer using the specified point.
public virtual byte this[Point point] { get; set; }
Parameters
pointPointThe 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 virtual byte this[int index] { get; set; }
Parameters
Property Value
StartPoint
Gets or sets the position from which this frame's area starts.
public virtual Point StartPoint { get; set; }
Property Value
Width
Gets the height of the buffer in pixel.
public int Width { get; }
Property Value
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 abstract void Clear(Color color)
Parameters
colorColorThe 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
colorColorThe color to fill the frame with.
Fill(Point, int, int, Color)
Fill the specific portion of the frame buffer with the specified color.
public abstract void Fill(Point start, int width, int height, Color color)
Parameters
startPointThe starting position.
widthintThe width of the area.
heightintThe height of the area.
colorColorThe color value to use.
GetFrameBufferIndexForPoint(Point)
Gets the index of the byte within the Buffer array which contains the specified point.
protected int GetFrameBufferIndexForPoint(Point point)
Parameters
Returns
GetFrameBufferIndexForPoint(int, int)
Gets the index of the byt within the Buffer array which contains the specified point.
protected int GetFrameBufferIndexForPoint(int x, int y)
Parameters
Returns
GetPixel(Point)
Gets the pixel at the specified position.
public abstract Color GetPixel(Point point)
Parameters
pointPointThe position to get the pixel from.
Returns
GetPointByteMask(Point)
Gets a byte mask pattern for the specified point.
protected byte GetPointByteMask(Point point)
Parameters
pointPointThe point within the frame buffer.
Returns
- byte
A byte mask pattern with the pixel bit flipped to 1.
IsPointWithinFrameBuffer(Point)
Checks if the specified point falls within the area this buffer is covering.
public virtual bool IsPointWithinFrameBuffer(Point point)
Parameters
pointPointThe 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 virtual bool IsRangeWithinFrameBuffer(Point start, Point end)
Parameters
Returns
- bool
True if the range is within this frame's area, otherwise; false.
SetPixel(Point, Color)
Sets the value of the pixel at the specified position.
public abstract void SetPixel(Point point, Color pixelColor)
Parameters
WriteBuffer(IFrameBuffer)
Copies the entire specified IFrameBuffer into the current frame buffer.
public void WriteBuffer(IFrameBuffer buffer)
Parameters
bufferIFrameBufferThe IFrameBuffer to copy from.
WriteBuffer(IFrameBuffer, Point)
Copies the specified IFrameBuffer into the current frame buffer.
public void WriteBuffer(IFrameBuffer buffer, Point destinationStart)
Parameters
bufferIFrameBufferThe IFrameBuffer to copy from.
destinationStartPointThe start point to begin writing to.
WriteBuffer(IFrameBuffer, Point, Point, Point)
Copies the specified IFrameBuffer into the current frame buffer.
public virtual void WriteBuffer(IFrameBuffer buffer, Point start, Point end, Point destinationStart)
Parameters
bufferIFrameBufferThe IFrameBuffer to copy from.
startPointThe start position to copy from.
endPointThe point at which copying from the buffer will stop.
destinationStartPointThe start point to begin writing to.
WriteBufferSlow(IFrameBuffer, Point, Point, Point)
Copies the specified IFrameBuffer to this instance by iterating every pixel. This can be a very slow operation but useful for when copying frames with incompatible bit depth.
protected virtual void WriteBufferSlow(IFrameBuffer buffer, Point start, Point end, Point destinationStart)
Parameters
bufferIFrameBufferThe buffer to copy from.
startPointThe starting point to copy from and write to.
endPointThe point at which copying from the buffer will stop.
destinationStartPointThe start point to begin writing to.