Table of Contents

Class ImageControl

Namespace
SharpConsoleUI.Controls
Assembly
SharpConsoleUI.dll

Displays a PixelBuffer as a half-block image in a console window. Each character cell represents 2 vertical pixels.

public class ImageControl : BaseControl, IWindowControl, IDisposable, IDOMPaintable, INotifyPropertyChanged
Inheritance
ImageControl
Implements
Inherited Members
Extension Methods

Properties

ContentWidth

Gets the minimum width needed to display the control's content, including margins. Returns null if width cannot be determined. This is calculated based on content (text length, child controls, etc.) and represents the natural/intrinsic size.

public override int? ContentWidth { get; }

Property Value

int?

ScaleMode

How the image scales to fit available space.

public ImageScaleMode ScaleMode { get; set; }

Property Value

ImageScaleMode

Source

The pixel buffer to render as an image.

public PixelBuffer? Source { get; set; }

Property Value

PixelBuffer

Methods

GetLogicalContentSize()

Gets the logical size of the control's content without rendering.

public override Size GetLogicalContentSize()

Returns

Size

The size representing the content's natural dimensions.

MeasureDOM(LayoutConstraints)

Measures the control's desired size given the available constraints.

public override LayoutSize MeasureDOM(LayoutConstraints constraints)

Parameters

constraints LayoutConstraints

The layout constraints (min/max width/height).

Returns

LayoutSize

The desired size of the control.

PaintDOM(CharacterBuffer, LayoutRect, LayoutRect, Color, Color)

Paints the control's content directly to a CharacterBuffer.

public override void PaintDOM(CharacterBuffer buffer, LayoutRect bounds, LayoutRect clipRect, Color defaultForeground, Color defaultBackground)

Parameters

buffer CharacterBuffer

The buffer to paint to.

bounds LayoutRect

The absolute bounds where the control should paint.

clipRect LayoutRect

The clipping rectangle (visible area).

defaultForeground Color

The default foreground color from the container.

defaultBackground Color

The default background color from the container.