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 raster-based (for terminals that support either the Sixel or Kitty graphics protocols).
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 UseRasterGraphics is true, the view renders through the best raster protocol available to the driver: Kitty graphics first, then Sixel. Raster data is only re-sent to the terminal when NeedsDraw is true, avoiding redundant rendering of unchanged images.
When no raster protocol is available, the view falls back to cell-based rendering where each terminal cell is colored with the background color of the corresponding pixel.
Constructors
- ImageView()
Initializes a new instance of the ImageView class.
Properties
- AllowSixelUpscaling
Gets or sets whether sixel rendering may upscale the visible image region above its source pixel size.
- DefaultKeyBindings
Gets or sets the default key bindings for ImageView.
- DefaultMouseBindings
Gets or sets the default mouse bindings for ImageView.
- 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.
- IsUsingRasterGraphics
Gets whether the current rendering mode is using a raster graphics protocol (Kitty or Sixel).
- IsUsingSixel
Gets whether the current rendering mode is using sixel.
- MaxSixelPaletteColors
Gets or sets the maximum number of colors to use when encoding ImageView sixel output.
- SixelEncoder
Gets or sets the SixelEncoder used to encode images as sixel data. When null, a default encoder is created lazily on first use.
- UseBackgroundRendering
Gets or sets whether ImageView scales image renders on a background thread.
- UseRasterGraphics
Gets or sets whether to prefer raster-graphics rendering (Kitty or Sixel protocol) when the terminal supports it. Default is true.
- ZoomLevel
Gets or sets the zoom level. A value of
1fits the image in the viewport.
Methods
- CenterOnViewportPoint(Point)
Centers the image on the specified viewport-relative point.
- 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.
- OnMouseEvent(Mouse)
Called when a mouse event occurs within the view's Viewport.
- 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.