Table of Contents

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

frameWidth int

Source frame width in pixels.

frameHeight int

Source frame height in pixels.

mode VideoRenderMode

Rendering 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

cellCols int

Target cell columns.

cellRows int

Target cell rows.

mode VideoRenderMode

Rendering 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

target Cell[,]

Pre-allocated Cell array to write into. Avoids per-frame GC allocation.

rgb24 byte[]

Raw pixel data: width * height * 3 bytes, row-major RGB.

frameWidth int

Source frame width in pixels.

frameHeight int

Source frame height in pixels.

mode VideoRenderMode

Rendering mode.

background Color

Background color for unfilled areas.

cellWidth int

Output cell array width actually written (columns).

cellHeight int

Output cell array height actually written (rows).