Table of Contents

Class PixelBuffer

Namespace
SharpConsoleUI.Imaging
Assembly
SharpConsoleUI.dll

A 2D buffer of RGB pixels used as the source for image rendering.

public class PixelBuffer
Inheritance
PixelBuffer
Inherited Members
Extension Methods

Constructors

PixelBuffer(int, int)

Creates a new pixel buffer with the specified dimensions.

public PixelBuffer(int width, int height)

Parameters

width int
height int

Properties

Height

Height in pixels.

public int Height { get; }

Property Value

int

Width

Width in pixels.

public int Width { get; }

Property Value

int

Methods

FromArgbArray(int[], int, int)

Creates a PixelBuffer from a flat array of ARGB 32-bit integers (alpha is ignored).

public static PixelBuffer FromArgbArray(int[] argbPixels, int width, int height)

Parameters

argbPixels int[]
width int
height int

Returns

PixelBuffer

FromFile(string)

Creates a PixelBuffer by loading an image from a file path. Supports PNG, JPEG, BMP, GIF, TIFF, TGA, PBM, and WebP formats.

public static PixelBuffer FromFile(string filePath)

Parameters

filePath string

Path to the image file.

Returns

PixelBuffer

A PixelBuffer containing the decoded image pixels.

FromImageSharp(Image<Rgb24>)

Creates a PixelBuffer from an ImageSharp Image<Rgb24>.

public static PixelBuffer FromImageSharp(Image<Rgb24> image)

Parameters

image Image<Rgb24>

Returns

PixelBuffer

FromPixelArray(ImagePixel[], int, int)

Creates a PixelBuffer from a flat pixel array in row-major order (left to right, top to bottom).

public static PixelBuffer FromPixelArray(ImagePixel[] pixels, int width, int height)

Parameters

pixels ImagePixel[]
width int
height int

Returns

PixelBuffer

FromStream(Stream)

Creates a PixelBuffer by loading an image from a stream. Supports PNG, JPEG, BMP, GIF, TIFF, TGA, PBM, and WebP formats.

public static PixelBuffer FromStream(Stream stream)

Parameters

stream Stream

Stream containing image data.

Returns

PixelBuffer

A PixelBuffer containing the decoded image pixels.

GetPixel(int, int)

Gets the pixel at the given coordinates. Returns default for out-of-bounds reads.

public ImagePixel GetPixel(int x, int y)

Parameters

x int
y int

Returns

ImagePixel

Resize(int, int)

Creates a new PixelBuffer resized to the target dimensions using bilinear interpolation.

public PixelBuffer Resize(int targetWidth, int targetHeight)

Parameters

targetWidth int
targetHeight int

Returns

PixelBuffer

SetPixel(int, int, ImagePixel)

Sets the pixel at the given coordinates. Out-of-bounds writes are silently ignored.

public void SetPixel(int x, int y, ImagePixel pixel)

Parameters

x int
y int
pixel ImagePixel