Class VideoFrameRenderer
- Namespace
- SharpConsoleUI.Video
- Assembly
- SharpConsoleUI.dll
Converts raw RGB24 frame bytes into Cell arrays for terminal display. Supports three render modes: HalfBlock, Ascii, and Braille.
public static class VideoFrameRenderer
- Inheritance
-
VideoFrameRenderer
- Inherited Members
Methods
GetCellDimensions(int, int, VideoRenderMode)
Computes the cell array dimensions for a given pixel frame size and render mode. Use this to pre-allocate the target array for RenderFrameInto(Cell[,], byte[], int, int, VideoRenderMode, Color, out int, out int).
public static (int CellWidth, int CellHeight) GetCellDimensions(int frameWidth, int frameHeight, VideoRenderMode mode)
Parameters
frameWidthintSource frame width in pixels.
frameHeightintSource frame height in pixels.
modeVideoRenderModeRendering mode.
Returns
- (int absoluteLeft, int absoluteTop)
Tuple of (CellWidth, CellHeight) for the target array dimensions.
GetRequiredPixelSize(int, int, VideoRenderMode)
Computes the required pixel dimensions for the given render mode and target cell size. FFmpeg should scale to these dimensions.
public static (int Width, int Height) GetRequiredPixelSize(int cellCols, int cellRows, VideoRenderMode mode)
Parameters
cellColsintTarget cell columns.
cellRowsintTarget cell rows.
modeVideoRenderModeRendering mode.
Returns
- (int absoluteLeft, int absoluteTop)
Tuple of (Width, Height) in pixels for FFmpeg scaling.
RenderFrameInto(Cell[,], byte[], int, int, VideoRenderMode, Color, out int, out int)
Renders a raw RGB24 frame into a pre-allocated Cell array.
Caller must ensure target is at least [cellWidth, cellHeight].
Use GetCellDimensions(int, int, VideoRenderMode) to compute the required array size.
public static void RenderFrameInto(Cell[,] target, byte[] rgb24, int frameWidth, int frameHeight, VideoRenderMode mode, Color background, out int cellWidth, out int cellHeight)
Parameters
targetCell[,]Pre-allocated Cell array to write into. Avoids per-frame GC allocation.
rgb24byte[]Raw pixel data: width * height * 3 bytes, row-major RGB.
frameWidthintSource frame width in pixels.
frameHeightintSource frame height in pixels.
modeVideoRenderModeRendering mode.
backgroundColorBackground color for unfilled areas.
cellWidthintOutput cell array width actually written (columns).
cellHeightintOutput cell array height actually written (rows).