Method Load
Load(string)
Loads an image from a file path, preserving its native pixel format. Grayscale images are loaded as GRAY8, images with alpha as RGBA32, and all others as RGB24.
public static ImageBuffer Load(string path)
Parameters
pathstringThe file path to load the image from.
Returns
- ImageBuffer
An ImageBuffer representing the loaded image in its native pixel format.
Exceptions
- ArgumentNullException
Thrown if
pathisnullor empty.- FileNotFoundException
Thrown if the file does not exist.
- InvalidOperationException
Thrown if loading fails.
Load(byte[])
Loads image data from a byte array, preserving the native pixel format.
public static ImageBuffer Load(byte[] data)
Parameters
databyte[]A byte array containing encoded image data (e.g., PNG or JPEG).
Returns
- ImageBuffer
An ImageBuffer in the most appropriate pixel format for the source image.
Exceptions
- ArgumentNullException
Thrown if
dataisnull.- ArgumentException
Thrown if
datais empty.- InvalidOperationException
Thrown if loading fails.
Load(ReadOnlyMemory<byte>)
Loads image data from a memory block, preserving the native pixel format.
public static ImageBuffer Load(ReadOnlyMemory<byte> data)
Parameters
dataReadOnlyMemory<byte>A ReadOnlyMemory<T> of bytes containing encoded image data.
Returns
- ImageBuffer
An ImageBuffer in the most appropriate pixel format for the source image.
Exceptions
- ArgumentException
Thrown if
datais empty.- InvalidOperationException
Thrown if loading fails.
Load(ReadOnlySpan<byte>)
Loads image data from a span, preserving the native pixel format.
public static ImageBuffer Load(ReadOnlySpan<byte> data)
Parameters
dataReadOnlySpan<byte>A ReadOnlySpan<T> of bytes containing encoded image data.
Returns
- ImageBuffer
An ImageBuffer in the most appropriate pixel format for the source image.
Exceptions
- ArgumentException
Thrown if
datais empty.- InvalidOperationException
Thrown if loading fails.