Class ImageView
Displays an image represented as a 2D array of Color pixels. Supports two rendering modes: cell-based (one colored space per pixel, works everywhere) and sixel-based (when the terminal supports it).
public class ImageView : View, IDisposable, ISupportInitializeNotification, ISupportInitialize, IDesignable
- Inheritance
-
ImageView
- Implements
- Inherited Members
- Extension Methods
Remarks
The image data is provided via the Image property as a Color[,] array
where the first dimension is width (x) and the second is height (y). Image loading and
decoding from file formats (PNG, JPEG, etc.) is the caller's responsibility — this view
has no dependency on any image library.
When sixel is available (detected via SixelSupport) and UseSixel is true, the view will encode the image as sixel escape sequences and render it through the driver's sixel pipeline. Sixel data is only re-encoded and re-sent to the terminal when NeedsDraw is true, avoiding redundant rendering of unchanged images.
When sixel is not available, the view falls back to cell-based rendering where each terminal cell is colored with the background color of the corresponding pixel.
Constructors
Properties
- Image
Gets or sets the pixel data to display. The array is indexed as [x, y] where the first dimension is width and the second is height.
- IsUsingSixel
Gets whether the current rendering mode is using sixel.
- SixelEncoder
Gets or sets the SixelEncoder used to encode images as sixel data. When null, a default encoder is created lazily on first use.
- UseSixel
Gets or sets whether to prefer sixel rendering when the terminal supports it. Default is true.
Methods
- Dispose(bool)
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
- FitImageInViewportCells(Size)
Returns the size in cell terms of the given image resized to fit in the viewport.
- FitImageInViewportInPixels(Size)
Scales an image to fit within the current Viewport while maintaining aspect ratio.
- OnDrawingContent(DrawContext?)
Called when the View's content is to be drawn. The default implementation does nothing.
- OnFrameChanged(in Rectangle)
Called when Frame changes.
- ScaleNearestNeighbor(Color[,], Color[,])
Scales a
Color[,]pixel array into a destination array using nearest-neighbor interpolation.
- ViewportToScreenInPixels()
Converts the Viewport to screen coordinates in pixels.