ConsoleForge 0.3.0
Elm-architecture TUI framework for .NET 8
Loading...
Searching...
No Matches
ConsoleForge.Widgets.ImageWidget Class Referencesealed

Renders an image inside its allocated terminal region. More...

Inheritance diagram for ConsoleForge.Widgets.ImageWidget:

Public Member Functions

 ImageWidget ()
 Object-initializer constructor.
 ImageWidget (byte[] pngData, TerminalCapabilities? capabilities=null)
 Positional constructor for Kitty / Auto rendering.
 ImageWidget (RgbaImageData rgbaData)
 Positional constructor for HalfBlock-only rendering (pre-decoded RGBA).
void Render (IRenderContext ctx)
 Render this widget into the provided context.The context carries the allocated region, theme, and color profile. Implementations MUST NOT write outside ctx.Region.

Properties

TerminalCapabilitiesCapabilities [get]
 Terminal capabilities detected at startup.
SizeConstraint Height = SizeConstraint.Flex(1) [get]
 Height constraint used by the layout engine.
byte?[] PngData [get]
 Raw PNG bytes used for Kitty rendering and (in Auto mode) as the primary source.
ImageRenderMode RenderMode = ImageRenderMode.Auto [get]
 Rendering strategy.
RgbaImageDataRgbaData [get]
 Pre-decoded RGBA pixel data used for the half-block fallback renderer.
Style Style = Style.Default [get]
 Visual style for this widget. Inherits from Theme if unset.
SizeConstraint Width = SizeConstraint.Flex(1) [get]
 Width constraint used by the layout engine.

Detailed Description

Renders an image inside its allocated terminal region.

Two render modes are available:

Set RenderMode to ImageRenderMode.Auto (default) to let the widget choose: Kitty when Capabilities reports support and PngData is present; HalfBlock when RgbaData is present; otherwise no-op.

Constructor & Destructor Documentation

◆ ImageWidget() [1/2]

ConsoleForge.Widgets.ImageWidget.ImageWidget ( byte[] pngData,
TerminalCapabilities? capabilities = null )

Positional constructor for Kitty / Auto rendering.

Parameters
pngDataRaw PNG bytes. The terminal handles decoding and scaling.
capabilitiesDetected terminal capabilities. When null, ImageRenderMode.Auto will fall back to HalfBlock (or no-op if RgbaData is also absent).

◆ ImageWidget() [2/2]

ConsoleForge.Widgets.ImageWidget.ImageWidget ( RgbaImageData rgbaData)

Positional constructor for HalfBlock-only rendering (pre-decoded RGBA).

Parameters
rgbaDataPre-decoded RGBA pixel data.

Property Documentation

◆ Capabilities

TerminalCapabilities? ConsoleForge.Widgets.ImageWidget.Capabilities
get

Terminal capabilities detected at startup.

Used by ImageRenderMode.Auto to decide between Kitty and HalfBlock. Inject via TerminalCapabilities.Detect at application start.

◆ PngData

byte? [] ConsoleForge.Widgets.ImageWidget.PngData
get

Raw PNG bytes used for Kitty rendering and (in Auto mode) as the primary source.

The terminal reads image dimensions from the PNG header; no pixel pre-processing is required by the application.

◆ RenderMode

ImageRenderMode ConsoleForge.Widgets.ImageWidget.RenderMode = ImageRenderMode.Auto
get

Rendering strategy.

Defaults to ImageRenderMode.Auto.

◆ RgbaData

RgbaImageData? ConsoleForge.Widgets.ImageWidget.RgbaData
get

Pre-decoded RGBA pixel data used for the half-block fallback renderer.

Required when RenderMode is ImageRenderMode.HalfBlock or when Auto mode cannot use Kitty.


The documentation for this class was generated from the following file:
  • src/ConsoleForge/Widgets/ImageWidget.cs