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
Properties
Height
Height in pixels.
public int Height { get; }
Property Value
Width
Width in pixels.
public int Width { get; }
Property Value
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
Returns
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
filePathstringPath 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
imageImage<Rgb24>
Returns
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
pixelsImagePixel[]widthintheightint
Returns
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
streamStreamStream 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
Returns
Resize(int, int)
Creates a new PixelBuffer resized to the target dimensions using bilinear interpolation.
public PixelBuffer Resize(int targetWidth, int targetHeight)
Parameters
Returns
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
xintyintpixelImagePixel