Method LoadAsRGB
LoadAsRGB(string)
Loads an image from the given file path, applies any necessary path fixes, and returns a new ImageBuffer in RGB24 format.
public static ImageBuffer LoadAsRGB(string path)
Parameters
path
stringThe file system path to the image file to load. May be a relative or absolute path; invalid segments will be corrected via TryFixPath(string).
Returns
- ImageBuffer
An ImageBuffer containing the decoded image data in RGB24 pixel format.
Exceptions
- ArgumentNullException
Thrown if
path
isnull
or an empty string.- FileNotFoundException
Thrown if no file exists at the corrected
path
.- InvalidOperationException
Thrown if loading the image from the resulting byte array fails.
LoadAsRGB(byte[])
Loads image data from the provided byte array and returns a new ImageBuffer in RGB24 format.
public static ImageBuffer LoadAsRGB(byte[] data)
Parameters
data
byte[]A byte array containing encoded image data (e.g., PNG or JPEG).
Returns
- ImageBuffer
An ImageBuffer representing the loaded image.
Exceptions
- ArgumentNullException
Thrown if
data
isnull
.- ArgumentException
Thrown if
data
is empty.- InvalidOperationException
Thrown if loading the image from bytes fails.
LoadAsRGB(ReadOnlyMemory<byte>)
Loads image data from the provided memory block and returns a new ImageBuffer in RGB24 format.
public static ImageBuffer LoadAsRGB(ReadOnlyMemory<byte> data)
Parameters
data
ReadOnlyMemory<byte>A ReadOnlyMemory<T> of bytes containing encoded image data.
Returns
- ImageBuffer
An ImageBuffer representing the loaded image.
Exceptions
- ArgumentException
Thrown if
data
is empty.- InvalidOperationException
Thrown if loading the image from bytes fails.
LoadAsRGB(ReadOnlySpan<byte>)
Loads image data from the provided span and returns a new ImageBuffer in RGB24 format.
public static ImageBuffer LoadAsRGB(ReadOnlySpan<byte> data)
Parameters
data
ReadOnlySpan<byte>A ReadOnlySpan<T> of bytes containing encoded image data.
Returns
- ImageBuffer
An ImageBuffer representing the loaded image.
Exceptions
- ArgumentException
Thrown if
data
is empty.- InvalidOperationException
Thrown if loading the image from bytes fails.