Skip to content

KgpImageWidget

Namespace: Hex1b.Widgets

Assembly: Hex1b.dll

A widget that displays a KGP (Kitty Graphics Protocol) image if the terminal supports it, otherwise falls back to rendering the fallback widget.

csharp
public sealed record KgpImageWidget : Hex1bWidget, IEquatable<Hex1bWidget>, IEquatable<KgpImageWidget>

Inheritance

ObjectHex1bWidgetKgpImageWidget

Implements

Constructors

KgpImageWidget(byte[], int, int, Hex1bWidget, int?, int?, KgpZOrder, KgpImageStretch)

A widget that displays a KGP (Kitty Graphics Protocol) image if the terminal supports it, otherwise falls back to rendering the fallback widget.

Parameters:

  • ImageData (Byte[]): Raw pixel data (RGBA32 format) for the image.
  • PixelWidth (Int32): Width of the image in pixels.
  • PixelHeight (Int32): Height of the image in pixels.
  • Fallback (Hex1bWidget): A widget to display if KGP is not supported.
  • Width (Nullable<Int32>): Optional width in character cells. If null, computed from pixel dimensions.
  • Height (Nullable<Int32>): Optional height in character cells. If null, computed from pixel dimensions.
  • ZOrder (KgpZOrder): Z-ordering relative to text. Default is .
  • Stretch (KgpImageStretch): How the image is scaled within its allocated cell area. Default is .
csharp
public KgpImageWidget(byte[] ImageData, int PixelWidth, int PixelHeight, Hex1bWidget Fallback, int? Width = null, int? Height = null, KgpZOrder ZOrder = KgpZOrder.BelowText, KgpImageStretch Stretch = KgpImageStretch.Stretch)

Properties

Fallback

A widget to display if KGP is not supported.

Returns: Hex1bWidget

csharp
public Hex1bWidget Fallback { get; init; }

Height

Optional height in character cells. If null, computed from pixel dimensions.

Returns: Nullable<Int32>

csharp
public int? Height { get; init; }

ImageData

Raw pixel data (RGBA32 format) for the image.

Returns: Byte[]

csharp
public byte[] ImageData { get; init; }

PixelHeight

Height of the image in pixels.

Returns: Int32

csharp
public int PixelHeight { get; init; }

PixelWidth

Width of the image in pixels.

Returns: Int32

csharp
public int PixelWidth { get; init; }

Stretch

How the image is scaled within its allocated cell area. Default is .

Returns: KgpImageStretch

csharp
public KgpImageStretch Stretch { get; init; }

Width

Optional width in character cells. If null, computed from pixel dimensions.

Returns: Nullable<Int32>

csharp
public int? Width { get; init; }

ZOrder

Z-ordering relative to text. Default is .

Returns: KgpZOrder

csharp
public KgpZOrder ZOrder { get; init; }

Released under the MIT License.