Skip to content

SixelFragment

Namespace: Hex1b.Surfaces

Assembly: Hex1b.dll

Represents a fragment of a sixel image after clipping or occlusion.

csharp
public sealed class SixelFragment

Inheritance

ObjectSixelFragment

Constructors

SixelFragment(SixelData, int, int, PixelRect)

Creates a new sixel fragment.

Parameters:

  • originalSixel (SixelData): The original sixel data.
  • cellX (Int32): The cell X position for rendering.
  • cellY (Int32): The cell Y position for rendering.
  • pixelRegion (PixelRect): The visible pixel region within the original.
csharp
public SixelFragment(SixelData originalSixel, int cellX, int cellY, PixelRect pixelRegion)

Properties

CellPosition

Gets the cell position where this fragment should be rendered.

Returns: ValueTuple<Int32, Int32>

csharp
public (int X, int Y) CellPosition { get; }

IsComplete

Gets whether this fragment represents the complete original sixel (no clipping).

Returns: Boolean

csharp
public bool IsComplete { get; }

OriginalSixel

Gets the original sixel data this fragment was derived from.

Returns: SixelData

csharp
public SixelData OriginalSixel { get; }

PixelRegion

Gets the pixel region within the original sixel that this fragment represents.

Returns: PixelRect

csharp
public PixelRect PixelRegion { get; }

Methods

Complete(SixelData, int, int)

Creates a fragment representing the complete original sixel.

Parameters:

Returns: SixelFragment

csharp
public static SixelFragment Complete(SixelData sixel, int cellX, int cellY)

GetCellSpan(CellMetrics)

Gets the cell span for this fragment using the specified metrics.

Parameters:

Returns: ValueTuple<Int32, Int32>

csharp
public (int Width, int Height) GetCellSpan(CellMetrics metrics)

GetPayload()

Gets the encoded sixel payload for this fragment. For complete fragments, returns the original payload. For cropped fragments, re-encodes the cropped pixels. The result is cached for subsequent calls.

Returns: String

The sixel payload string, or null if encoding fails.

csharp
public string? GetPayload()

GetPixels()

Gets the cropped pixel buffer for this fragment. The result is cached for subsequent calls.

Returns: SixelPixelBuffer

The cropped pixel buffer, or null if the original cannot be decoded.

csharp
public SixelPixelBuffer? GetPixels()

Remarks

When a sixel is partially occluded by overlapping content, it may be split into multiple fragments. Each fragment contains the visible portion of the original sixel along with its position.

Released under the MIT License.