Class DecodedImage
Image decoded to 8-bit RGBA pixels, row by row from the top.
Implements
Inherited Members
Namespace: Uniform.Chat.Terminal.Ui.Images
Assembly: Uniform.Chat.dll
Syntax
public sealed record DecodedImage : IEquatable<DecodedImage>
Constructors
| Edit this page View SourceDecodedImage(int, int, byte[])
Image decoded to 8-bit RGBA pixels, row by row from the top.
Declaration
public DecodedImage(int Width, int Height, byte[] Rgba)
Parameters
| Type | Name | Description |
|---|---|---|
| int | Width | Width in pixels. |
| int | Height | Height in pixels. |
| byte[] | Rgba | Four bytes per pixel. |
Fields
| Edit this page View SourceMaxDimension
Largest dimension accepted, to bound memory for hostile or huge images.
Declaration
public const int MaxDimension = 8192
Field Value
| Type | Description |
|---|---|
| int |
Properties
| Edit this page View SourceHeight
Height in pixels.
Declaration
public int Height { get; init; }
Property Value
| Type | Description |
|---|---|
| int |
Rgba
Four bytes per pixel.
Declaration
public byte[] Rgba { get; init; }
Property Value
| Type | Description |
|---|---|
| byte[] |
Width
Width in pixels.
Declaration
public int Width { get; init; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
| Edit this page View SourceDownscale(int)
Return a copy no larger than maxDimension on either side, using nearest-neighbor sampling; return itself when already small enough.
Declaration
public DecodedImage Downscale(int maxDimension)
Parameters
| Type | Name | Description |
|---|---|---|
| int | maxDimension |
Returns
| Type | Description |
|---|---|
| DecodedImage |
GetPixel(int, int)
Return the pixel at (x, y) as red, green, blue and alpha.
Declaration
public (byte R, byte G, byte B, byte A) GetPixel(int x, int y)
Parameters
| Type | Name | Description |
|---|---|---|
| int | x | |
| int | y |
Returns
| Type | Description |
|---|---|
| (byte R, byte G, byte B, byte A) |
ToColors()
Convert to the [x, y] color array of Terminal.Gui.Views.ImageView.
Declaration
public Color[,] ToColors()
Returns
| Type | Description |
|---|---|
| Color[,] |
TryDecode(byte[])
Decode PNG, JPEG, GIF (first frame), BMP, TGA or PSD; return null for other or broken data.
Declaration
public static DecodedImage? TryDecode(byte[] data)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | data |
Returns
| Type | Description |
|---|---|
| DecodedImage |