Class Image
Encapsulates an image, which consists of the pixel data for a graphics image and its attributes. For the non-generic Image type, the pixel type is only known at runtime. Image is always implemented by a pixel-specific Image<TPixel> instance.
Inherited Members
Namespace: SixLabors.ImageSharp
Assembly: SixLabors.ImageSharp.dll
Syntax
public abstract class Image : IImage, IImageInfo, IDisposable
Constructors
| Improve this Doc View SourceImage(Configuration, PixelTypeInfo, ImageMetadata, Size)
Initializes a new instance of the Image class.
Declaration
protected Image(Configuration configuration, PixelTypeInfo pixelType, ImageMetadata metadata, Size size)
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The configuration which allows altering default behaviour or extending the library. |
| PixelTypeInfo | pixelType | The PixelTypeInfo. |
| ImageMetadata | metadata | The ImageMetadata. |
| Size | size | The SixLabors.ImageSharp.Image.size. |
Properties
| Improve this Doc View SourceFrames
Gets the frames of the image as (non-generic) ImageFrameCollection.
Declaration
public ImageFrameCollection Frames { get; }
Property Value
| Type | Description |
|---|---|
| ImageFrameCollection |
Height
Gets the height.
Declaration
public int Height { get; }
Property Value
| Type | Description |
|---|---|
| Int32 |
Metadata
Gets the metadata of the image.
Declaration
public ImageMetadata Metadata { get; }
Property Value
| Type | Description |
|---|---|
| ImageMetadata |
NonGenericFrameCollection
Gets the ImageFrameCollection implementing the public Frames property.
Declaration
protected abstract ImageFrameCollection NonGenericFrameCollection { get; }
Property Value
| Type | Description |
|---|---|
| ImageFrameCollection |
PixelType
Gets information about the image pixels.
Declaration
public PixelTypeInfo PixelType { get; }
Property Value
| Type | Description |
|---|---|
| PixelTypeInfo |
Width
Gets the width.
Declaration
public int Width { get; }
Property Value
| Type | Description |
|---|---|
| Int32 |
Methods
| Improve this Doc View SourceCloneAs<TPixel2>()
Returns a copy of the image in the given pixel format.
Declaration
public Image<TPixel2> CloneAs<TPixel2>()
where TPixel2 : struct, IPixel<TPixel2>
Returns
| Type | Description |
|---|---|
| Image<TPixel2> | The Image<TPixel> |
Type Parameters
| Name | Description |
|---|---|
| TPixel2 | The pixel format. |
CloneAs<TPixel2>(Configuration)
Returns a copy of the image in the given pixel format.
Declaration
public abstract Image<TPixel2> CloneAs<TPixel2>(Configuration configuration)
where TPixel2 : struct, IPixel<TPixel2>
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The configuration providing initialization code which allows extending the library. |
Returns
| Type | Description |
|---|---|
| Image<TPixel2> | The Image<TPixel>. |
Type Parameters
| Name | Description |
|---|---|
| TPixel2 | The pixel format. |
DetectFormat(Configuration, Byte[])
By reading the header on the provided byte array this calculates the images format.
Declaration
public static IImageFormat DetectFormat(Configuration configuration, byte[] data)
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The configuration. |
| Byte[] | data | The byte array containing encoded image data to read the header from. |
Returns
| Type | Description |
|---|---|
| IImageFormat | The mime type or null if none found. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentNullException | The data is null. |
DetectFormat(Configuration, Stream)
By reading the header on the provided stream this calculates the images format type.
Declaration
public static IImageFormat DetectFormat(Configuration configuration, Stream stream)
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The configuration. |
| Stream | stream | The image stream to read the header from. |
Returns
| Type | Description |
|---|---|
| IImageFormat | The format type or null if none found. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentNullException | The stream is null. |
| NotSupportedException | The stream is not readable. |
DetectFormat(Configuration, ReadOnlySpan<Byte>)
By reading the header on the provided byte span this calculates the images format.
Declaration
public static IImageFormat DetectFormat(Configuration configuration, ReadOnlySpan<byte> data)
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The configuration. |
| ReadOnlySpan<Byte> | data | The byte span containing encoded image data to read the header from. |
Returns
| Type | Description |
|---|---|
| IImageFormat | The mime type or null if none found. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
DetectFormat(Configuration, String)
By reading the header on the provided file this calculates the images mime type.
Declaration
public static IImageFormat DetectFormat(Configuration configuration, string filePath)
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The configuration. |
| String | filePath | The image file to open and to read the header from. |
Returns
| Type | Description |
|---|---|
| IImageFormat | The mime type or null if none found. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
DetectFormat(Byte[])
By reading the header on the provided byte array this calculates the images format.
Declaration
public static IImageFormat DetectFormat(byte[] data)
Parameters
| Type | Name | Description |
|---|---|---|
| Byte[] | data | The byte array containing encoded image data to read the header from. |
Returns
| Type | Description |
|---|---|
| IImageFormat | The format or null if none found. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The data is null. |
DetectFormat(Stream)
By reading the header on the provided stream this calculates the images format type.
Declaration
public static IImageFormat DetectFormat(Stream stream)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream | The image stream to read the header from. |
Returns
| Type | Description |
|---|---|
| IImageFormat | The format type or null if none found. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The stream is null. |
| NotSupportedException | The stream is not readable. |
DetectFormat(ReadOnlySpan<Byte>)
By reading the header on the provided byte span this calculates the images format.
Declaration
public static IImageFormat DetectFormat(ReadOnlySpan<byte> data)
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlySpan<Byte> | data | The byte span containing encoded image data to read the header from. |
Returns
| Type | Description |
|---|---|
| IImageFormat | The format or null if none found. |
DetectFormat(String)
By reading the header on the provided file this calculates the images mime type.
Declaration
public static IImageFormat DetectFormat(string filePath)
Parameters
| Type | Name | Description |
|---|---|---|
| String | filePath | The image file to open and to read the header from. |
Returns
| Type | Description |
|---|---|
| IImageFormat | The mime type or null if none found. |
DetectFormatAsync(Configuration, Stream)
By reading the header on the provided stream this calculates the images format type.
Declaration
public static Task<IImageFormat> DetectFormatAsync(Configuration configuration, Stream stream)
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The configuration. |
| Stream | stream | The image stream to read the header from. |
Returns
| Type | Description |
|---|---|
| Task<IImageFormat> | A Task<TResult> representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentNullException | The stream is null. |
| NotSupportedException | The stream is not readable. |
DetectFormatAsync(Stream)
By reading the header on the provided stream this calculates the images format type.
Declaration
public static Task<IImageFormat> DetectFormatAsync(Stream stream)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream | The image stream to read the header from. |
Returns
| Type | Description |
|---|---|
| Task<IImageFormat> | A Task<TResult> representing the asynchronous operation or null if none is found. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The stream is null. |
| NotSupportedException | The stream is not readable. |
Dispose()
Declaration
public void Dispose()
Dispose(Boolean)
Disposes the object and frees resources for the Garbage Collector.
Declaration
protected abstract void Dispose(bool disposing)
Parameters
| Type | Name | Description |
|---|---|---|
| Boolean | disposing | Whether to dispose of managed and unmanaged objects. |
Identify(Configuration, Byte[], out IImageFormat)
Reads the raw image information from the specified stream without fully decoding it.
Declaration
public static IImageInfo Identify(Configuration configuration, byte[] data, out IImageFormat format)
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The configuration. |
| Byte[] | data | The byte array containing encoded image data to read the header from. |
| IImageFormat | format | The format type of the decoded image. |
Returns
| Type | Description |
|---|---|
| IImageInfo | The IImageInfo or null if suitable info detector is not found. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentNullException | The data is null. |
| NotSupportedException | The data is not readable. |
Identify(Configuration, Stream)
Reads the raw image information from the specified stream without fully decoding it.
Declaration
public static IImageInfo Identify(Configuration configuration, Stream stream)
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The configuration. |
| Stream | stream | The image stream to read the information from. |
Returns
| Type | Description |
|---|---|
| IImageInfo | The IImageInfo or null if a suitable info detector is not found. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentNullException | The stream is null. |
| NotSupportedException | The stream is not readable. |
| InvalidImageContentException | Image contains invalid content. |
Identify(Configuration, Stream, out IImageFormat)
Reads the raw image information from the specified stream without fully decoding it.
Declaration
public static IImageInfo Identify(Configuration configuration, Stream stream, out IImageFormat format)
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The configuration. |
| Stream | stream | The image stream to read the information from. |
| IImageFormat | format | The format type of the decoded image. |
Returns
| Type | Description |
|---|---|
| IImageInfo | The IImageInfo or null if a suitable info detector is not found. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentNullException | The stream is null. |
| NotSupportedException | The stream is not readable. |
| InvalidImageContentException | Image contains invalid content. |
Identify(Configuration, String, out IImageFormat)
Reads the raw image information from the specified stream without fully decoding it.
Declaration
public static IImageInfo Identify(Configuration configuration, string filePath, out IImageFormat format)
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The configuration. |
| String | filePath | The image file to open and to read the header from. |
| IImageFormat | format | The format type of the decoded image. |
Returns
| Type | Description |
|---|---|
| IImageInfo | The IImageInfo or null if suitable info detector is not found. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
Identify(Byte[])
Reads the raw image information from the specified stream without fully decoding it.
Declaration
public static IImageInfo Identify(byte[] data)
Parameters
| Type | Name | Description |
|---|---|---|
| Byte[] | data | The byte array containing encoded image data to read the header from. |
Returns
| Type | Description |
|---|---|
| IImageInfo | The IImageInfo or null if suitable info detector not found. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The data is null. |
| NotSupportedException | The data is not readable. |
Identify(Byte[], out IImageFormat)
Reads the raw image information from the specified stream without fully decoding it.
Declaration
public static IImageInfo Identify(byte[] data, out IImageFormat format)
Parameters
| Type | Name | Description |
|---|---|---|
| Byte[] | data | The byte array containing encoded image data to read the header from. |
| IImageFormat | format | The format type of the decoded image. |
Returns
| Type | Description |
|---|---|
| IImageInfo | The IImageInfo or null if suitable info detector not found. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The data is null. |
| NotSupportedException | The data is not readable. |
Identify(Stream)
Reads the raw image information from the specified stream without fully decoding it.
Declaration
public static IImageInfo Identify(Stream stream)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream | The image stream to read the header from. |
Returns
| Type | Description |
|---|---|
| IImageInfo | The IImageInfo or null if a suitable info detector is not found. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The stream is null. |
| NotSupportedException | The stream is not readable. |
| InvalidImageContentException | Image contains invalid content. |
Identify(Stream, out IImageFormat)
Reads the raw image information from the specified stream without fully decoding it.
Declaration
public static IImageInfo Identify(Stream stream, out IImageFormat format)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream | The image stream to read the header from. |
| IImageFormat | format | The format type of the decoded image. |
Returns
| Type | Description |
|---|---|
| IImageInfo | The IImageInfo or null if a suitable info detector is not found. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The stream is null. |
| NotSupportedException | The stream is not readable. |
| InvalidImageContentException | Image contains invalid content. |
Identify(String)
Reads the raw image information from the specified stream without fully decoding it.
Declaration
public static IImageInfo Identify(string filePath)
Parameters
| Type | Name | Description |
|---|---|---|
| String | filePath | The image file to open and to read the header from. |
Returns
| Type | Description |
|---|---|
| IImageInfo | The IImageInfo or null if suitable info detector not found. |
Identify(String, out IImageFormat)
Reads the raw image information from the specified stream without fully decoding it.
Declaration
public static IImageInfo Identify(string filePath, out IImageFormat format)
Parameters
| Type | Name | Description |
|---|---|---|
| String | filePath | The image file to open and to read the header from. |
| IImageFormat | format | The format type of the decoded image. |
Returns
| Type | Description |
|---|---|
| IImageInfo | The IImageInfo or null if suitable info detector not found. |
IdentifyAsync(Configuration, Stream, CancellationToken)
Reads the raw image information from the specified stream without fully decoding it.
Declaration
public static async Task<IImageInfo> IdentifyAsync(Configuration configuration, Stream stream, CancellationToken cancellationToken = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The configuration. |
| Stream | stream | The image stream to read the information from. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task<IImageInfo> | A Task<TResult> representing the asynchronous operation or null if a suitable detector is not found. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentNullException | The stream is null. |
| NotSupportedException | The stream is not readable. |
| InvalidImageContentException | Image contains invalid content. |
IdentifyAsync(Configuration, String, CancellationToken)
Reads the raw image information from the specified stream without fully decoding it.
Declaration
public static async Task<IImageInfo> IdentifyAsync(Configuration configuration, string filePath, CancellationToken cancellationToken = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The configuration. |
| String | filePath | The image file to open and to read the header from. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task<IImageInfo> | The Task<TResult> representing the asynchronous operation with the parameter type IImageInfo property set to null if suitable info detector is not found. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
IdentifyAsync(Stream)
Reads the raw image information from the specified stream without fully decoding it.
Declaration
public static Task<IImageInfo> IdentifyAsync(Stream stream)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream | The image stream to read the header from. |
Returns
| Type | Description |
|---|---|
| Task<IImageInfo> | A Task<TResult> representing the asynchronous operation or null if a suitable detector is not found. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The stream is null. |
| NotSupportedException | The stream is not readable. |
| InvalidImageContentException | Image contains invalid content. |
IdentifyAsync(String, CancellationToken)
Reads the raw image information from the specified stream without fully decoding it.
Declaration
public static Task<IImageInfo> IdentifyAsync(string filePath, CancellationToken cancellationToken = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| String | filePath | The image file to open and to read the header from. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task<IImageInfo> | The Task<TResult> representing the asynchronous operation with the parameter type IImageInfo property set to null if suitable info detector is not found. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
IdentifyWithFormatAsync(Configuration, Stream, CancellationToken)
Reads the raw image information from the specified stream without fully decoding it.
Declaration
public static Task<(IImageInfo ImageInfo, IImageFormat Format)> IdentifyWithFormatAsync(Configuration configuration, Stream stream, CancellationToken cancellationToken = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The configuration. |
| Stream | stream | The image stream to read the information from. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task<(T1, T2)<IImageInfo, IImageFormat>> | The Task<TResult> representing the asynchronous operation with the parameter type IImageInfo property set to null if suitable info detector is not found. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentNullException | The stream is null. |
| NotSupportedException | The stream is not readable. |
| InvalidImageContentException | Image contains invalid content. |
IdentifyWithFormatAsync(Configuration, String, CancellationToken)
Reads the raw image information from the specified stream without fully decoding it.
Declaration
public static async Task<(IImageInfo ImageInfo, IImageFormat Format)> IdentifyWithFormatAsync(Configuration configuration, string filePath, CancellationToken cancellationToken = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The configuration. |
| String | filePath | The image file to open and to read the header from. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task<(T1, T2)<IImageInfo, IImageFormat>> | The Task<TResult> representing the asynchronous operation with the parameter type IImageInfo property set to null if suitable info detector is not found. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
IdentifyWithFormatAsync(Stream, CancellationToken)
Reads the raw image information from the specified stream without fully decoding it.
Declaration
public static Task<(IImageInfo ImageInfo, IImageFormat Format)> IdentifyWithFormatAsync(Stream stream, CancellationToken cancellationToken = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream | The image stream to read the information from. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task<(T1, T2)<IImageInfo, IImageFormat>> | The Task<TResult> representing the asynchronous operation with the parameter type IImageInfo property set to null if suitable info detector is not found. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentNullException | The stream is null. |
| NotSupportedException | The stream is not readable. |
| InvalidImageContentException | Image contains invalid content. |
IdentifyWithFormatAsync(String, CancellationToken)
Reads the raw image information from the specified stream without fully decoding it.
Declaration
public static Task<(IImageInfo ImageInfo, IImageFormat Format)> IdentifyWithFormatAsync(string filePath, CancellationToken cancellationToken = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| String | filePath | The image file to open and to read the header from. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task<(T1, T2)<IImageInfo, IImageFormat>> | The Task<TResult> representing the asynchronous operation with the parameter type IImageInfo property set to null if suitable info detector is not found. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
Load(Configuration, Byte[])
Load a new instance of Image from the given encoded byte array.
Declaration
public static Image Load(Configuration configuration, byte[] data)
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The configuration for the decoder. |
| Byte[] | data | The byte array containing encoded image data. |
Returns
| Type | Description |
|---|---|
| Image | The Image. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentNullException | The data is null. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
Load(Configuration, Byte[], IImageDecoder)
Load a new instance of Image from the given encoded byte array.
Declaration
public static Image Load(Configuration configuration, byte[] data, IImageDecoder decoder)
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The configuration for the decoder. |
| Byte[] | data | The byte array containing image data. |
| IImageDecoder | decoder | The decoder. |
Returns
| Type | Description |
|---|---|
| Image | The Image. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentNullException | The data is null. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
Load(Configuration, Byte[], out IImageFormat)
Load a new instance of Image from the given encoded byte array.
Declaration
public static Image Load(Configuration configuration, byte[] data, out IImageFormat format)
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The configuration for the decoder. |
| Byte[] | data | The byte array containing image data. |
| IImageFormat | format | The mime type of the decoded image. |
Returns
| Type | Description |
|---|---|
| Image | The Image. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentNullException | The data is null. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
Load(Configuration, Stream)
Decode a new instance of the Image class from the given stream.
Declaration
public static Image Load(Configuration configuration, Stream stream)
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The configuration for the decoder. |
| Stream | stream | The stream containing image information. |
Returns
| Type | Description |
|---|---|
| Image | A new Image. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentNullException | The stream is null. |
| NotSupportedException | The stream is not readable. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
Load(Configuration, Stream, IImageDecoder)
Decode a new instance of the Image class from the given stream. The pixel format is selected by the decoder.
Declaration
public static Image Load(Configuration configuration, Stream stream, IImageDecoder decoder)
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The configuration for the decoder. |
| Stream | stream | The stream containing image information. |
| IImageDecoder | decoder | The decoder. |
Returns
| Type | Description |
|---|---|
| Image | A new Image. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentNullException | The stream is null. |
| ArgumentNullException | The decoder is null. |
| NotSupportedException | The stream is not readable. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
Load(Configuration, Stream, out IImageFormat)
Decode a new instance of the Image class from the given stream. The pixel format is selected by the decoder.
Declaration
public static Image Load(Configuration configuration, Stream stream, out IImageFormat format)
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The configuration options. |
| Stream | stream | The stream containing image information. |
| IImageFormat | format | The format type of the decoded image. |
Returns
| Type | Description |
|---|---|
| Image | A new Image<TPixel>. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentNullException | The stream is null. |
| NotSupportedException | The stream is not readable. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
Load(Configuration, ReadOnlySpan<Byte>)
Decodes a new instance of Image from the given encoded byte span.
Declaration
public static Image Load(Configuration configuration, ReadOnlySpan<byte> data)
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The configuration options. |
| ReadOnlySpan<Byte> | data | The byte span containing image data. |
Returns
| Type | Description |
|---|---|
| Image | The Image. |
Load(Configuration, ReadOnlySpan<Byte>, IImageDecoder)
Load a new instance of Image from the given encoded byte span.
Declaration
public static Image Load(Configuration configuration, ReadOnlySpan<byte> data, IImageDecoder decoder)
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The Configuration. |
| ReadOnlySpan<Byte> | data | The byte span containing image data. |
| IImageDecoder | decoder | The decoder. |
Returns
| Type | Description |
|---|---|
| Image | The Image. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentNullException | The decoder is null. |
| NotSupportedException | The stream is not readable. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
Load(Configuration, ReadOnlySpan<Byte>, out IImageFormat)
Load a new instance of Image from the given encoded byte span.
Declaration
public static Image Load(Configuration configuration, ReadOnlySpan<byte> data, out IImageFormat format)
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The configuration options. |
| ReadOnlySpan<Byte> | data | The byte span containing image data. |
| IImageFormat | format | The IImageFormat of the decoded image. |
Returns
| Type | Description |
|---|---|
| Image | The Image. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
Load(Configuration, String)
Create a new instance of the Image class from the given file.
Declaration
public static Image Load(Configuration configuration, string path)
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The configuration for the decoder. |
| String | path | The file path to the image. |
Returns
| Type | Description |
|---|---|
| Image | The Image. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentNullException | The path is null. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
Load(Configuration, String, IImageDecoder)
Create a new instance of the Image class from the given file.
Declaration
public static Image Load(Configuration configuration, string path, IImageDecoder decoder)
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The Configuration. |
| String | path | The file path to the image. |
| IImageDecoder | decoder | The decoder. |
Returns
| Type | Description |
|---|---|
| Image | The Image. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentNullException | The path is null. |
| ArgumentNullException | The decoder is null. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
Load(Configuration, String, out IImageFormat)
Create a new instance of the Image class from the given file. The pixel type is selected by the decoder.
Declaration
public static Image Load(Configuration configuration, string path, out IImageFormat format)
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The configuration options. |
| String | path | The file path to the image. |
| IImageFormat | format | The mime type of the decoded image. |
Returns
| Type | Description |
|---|---|
| Image | A new Image<TPixel>. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentNullException | The path is null. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
Load(Byte[])
Load a new instance of Image<TPixel> from the given encoded byte array.
Declaration
public static Image<Rgba32> Load(byte[] data)
Parameters
| Type | Name | Description |
|---|---|---|
| Byte[] | data | The byte array containing image data. |
Returns
| Type | Description |
|---|---|
| Image<Rgba32> | A new Image<TPixel>. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentNullException | The data is null. |
Load(Byte[], IImageDecoder)
Load a new instance of Image from the given encoded byte array.
Declaration
public static Image Load(byte[] data, IImageDecoder decoder)
Parameters
| Type | Name | Description |
|---|---|---|
| Byte[] | data | The byte array containing encoded image data. |
| IImageDecoder | decoder | The decoder. |
Returns
| Type | Description |
|---|---|
| Image | The Image. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The data is null. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
Load(Byte[], out IImageFormat)
Load a new instance of Image from the given encoded byte array.
Declaration
public static Image Load(byte[] data, out IImageFormat format)
Parameters
| Type | Name | Description |
|---|---|---|
| Byte[] | data | The byte array containing image data. |
| IImageFormat | format | The detected format. |
Returns
| Type | Description |
|---|---|
| Image | The Image. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentNullException | The data is null. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
Load(Stream)
Decode a new instance of the Image class from the given stream. The pixel format is selected by the decoder.
Declaration
public static Image Load(Stream stream)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream | The stream containing image information. |
Returns
| Type | Description |
|---|---|
| Image | The Image. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The stream is null. |
| NotSupportedException | The stream is not readable. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
Load(Stream, IImageDecoder)
Decode a new instance of the Image class from the given stream. The pixel format is selected by the decoder.
Declaration
public static Image Load(Stream stream, IImageDecoder decoder)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream | The stream containing image information. |
| IImageDecoder | decoder | The decoder. |
Returns
| Type | Description |
|---|---|
| Image | The Image. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The stream is null. |
| ArgumentNullException | The decoder is null. |
| NotSupportedException | The stream is not readable. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
Load(Stream, out IImageFormat)
Decode a new instance of the Image class from the given stream. The pixel format is selected by the decoder.
Declaration
public static Image Load(Stream stream, out IImageFormat format)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream | The stream containing image information. |
| IImageFormat | format | The format type of the decoded image. |
Returns
| Type | Description |
|---|---|
| Image | The Image. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The stream is null. |
| NotSupportedException | The stream is not readable. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
Load(ReadOnlySpan<Byte>)
Load a new instance of Image from the given encoded byte span.
Declaration
public static Image Load(ReadOnlySpan<byte> data)
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlySpan<Byte> | data | The byte span containing image data. |
Returns
| Type | Description |
|---|---|
| Image | The Image. |
Exceptions
| Type | Condition |
|---|---|
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
Load(ReadOnlySpan<Byte>, IImageDecoder)
Load a new instance of Image from the given encoded byte span.
Declaration
public static Image Load(ReadOnlySpan<byte> data, IImageDecoder decoder)
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlySpan<Byte> | data | The byte span containing image data. |
| IImageDecoder | decoder | The decoder. |
Returns
| Type | Description |
|---|---|
| Image | The Image. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The data is null. |
| ArgumentNullException | The decoder is null. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
Load(ReadOnlySpan<Byte>, out IImageFormat)
Load a new instance of Image from the given encoded byte array.
Declaration
public static Image Load(ReadOnlySpan<byte> data, out IImageFormat format)
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlySpan<Byte> | data | The byte span containing image data. |
| IImageFormat | format | The detected format. |
Returns
| Type | Description |
|---|---|
| Image | The Image. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The decoder is null. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
Load(String)
Create a new instance of the Image class from the given file.
Declaration
public static Image Load(string path)
Parameters
| Type | Name | Description |
|---|---|---|
| String | path | The file path to the image. |
Returns
| Type | Description |
|---|---|
| Image | The Image. |
Exceptions
| Type | Condition |
|---|---|
| NotSupportedException | Thrown if the stream is not readable nor seekable. |
Load(String, IImageDecoder)
Create a new instance of the Image class from the given file.
Declaration
public static Image Load(string path, IImageDecoder decoder)
Parameters
| Type | Name | Description |
|---|---|---|
| String | path | The file path to the image. |
| IImageDecoder | decoder | The decoder. |
Returns
| Type | Description |
|---|---|
| Image | The Image. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The path is null. |
| ArgumentNullException | The decoder is null. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
Load(String, out IImageFormat)
Create a new instance of the Image class from the given file.
Declaration
public static Image Load(string path, out IImageFormat format)
Parameters
| Type | Name | Description |
|---|---|---|
| String | path | The file path to the image. |
| IImageFormat | format | The mime type of the decoded image. |
Returns
| Type | Description |
|---|---|
| Image | A new Image<TPixel>. |
Exceptions
| Type | Condition |
|---|---|
| NotSupportedException | Thrown if the stream is not readable nor seekable. |
Load<TPixel>(Configuration, Byte[])
Load a new instance of Image<TPixel> from the given encoded byte array.
Declaration
public static Image<TPixel> Load<TPixel>(Configuration configuration, byte[] data)
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The configuration options. |
| Byte[] | data | The byte array containing encoded image data. |
Returns
| Type | Description |
|---|---|
| Image<TPixel> | A new Image<TPixel>. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel format. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentNullException | The data is null. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
Load<TPixel>(Configuration, Byte[], IImageDecoder)
Load a new instance of Image<TPixel> from the given encoded byte array.
Declaration
public static Image<TPixel> Load<TPixel>(Configuration configuration, byte[] data, IImageDecoder decoder)
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The Configuration. |
| Byte[] | data | The byte array containing encoded image data. |
| IImageDecoder | decoder | The decoder. |
Returns
| Type | Description |
|---|---|
| Image<TPixel> | A new Image<TPixel>. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel format. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentNullException | The data is null. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
Load<TPixel>(Configuration, Byte[], out IImageFormat)
Load a new instance of Image<TPixel> from the given encoded byte array.
Declaration
public static Image<TPixel> Load<TPixel>(Configuration configuration, byte[] data, out IImageFormat format)
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The configuration options. |
| Byte[] | data | The byte array containing encoded image data. |
| IImageFormat | format | The IImageFormat of the decoded image. |
Returns
| Type | Description |
|---|---|
| Image<TPixel> | A new Image<TPixel>. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel format. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentNullException | The data is null. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
Load<TPixel>(Configuration, Stream)
Create a new instance of the Image<TPixel> class from the given stream.
Declaration
public static Image<TPixel> Load<TPixel>(Configuration configuration, Stream stream)
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The configuration options. |
| Stream | stream | The stream containing image information. |
Returns
| Type | Description |
|---|---|
| Image<TPixel> | A new Image<TPixel>. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel format. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentNullException | The stream is null. |
| NotSupportedException | The stream is not readable. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
Load<TPixel>(Configuration, Stream, IImageDecoder)
Create a new instance of the Image<TPixel> class from the given stream.
Declaration
public static Image<TPixel> Load<TPixel>(Configuration configuration, Stream stream, IImageDecoder decoder)
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The Configuration. |
| Stream | stream | The stream containing image information. |
| IImageDecoder | decoder | The decoder. |
Returns
| Type | Description |
|---|---|
| Image<TPixel> | A new Image<TPixel>. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel format. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentNullException | The stream is null. |
| NotSupportedException | The stream is not readable. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
Load<TPixel>(Configuration, Stream, out IImageFormat)
Create a new instance of the Image<TPixel> class from the given stream.
Declaration
public static Image<TPixel> Load<TPixel>(Configuration configuration, Stream stream, out IImageFormat format)
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The configuration options. |
| Stream | stream | The stream containing image information. |
| IImageFormat | format | The format type of the decoded image. |
Returns
| Type | Description |
|---|---|
| Image<TPixel> | A Task representing the asynchronous operation. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel format. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentNullException | The stream is null. |
| NotSupportedException | The stream is not readable. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
Load<TPixel>(Configuration, ReadOnlySpan<Byte>)
Load a new instance of Image<TPixel> from the given encoded byte span.
Declaration
public static Image<TPixel> Load<TPixel>(Configuration configuration, ReadOnlySpan<byte> data)
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The configuration options. |
| ReadOnlySpan<Byte> | data | The byte span containing encoded image data. |
Returns
| Type | Description |
|---|---|
| Image<TPixel> | A new Image<TPixel>. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel format. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
Load<TPixel>(Configuration, ReadOnlySpan<Byte>, IImageDecoder)
Load a new instance of Image<TPixel> from the given encoded byte span.
Declaration
public static Image<TPixel> Load<TPixel>(Configuration configuration, ReadOnlySpan<byte> data, IImageDecoder decoder)
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The Configuration. |
| ReadOnlySpan<Byte> | data | The byte span containing image data. |
| IImageDecoder | decoder | The decoder. |
Returns
| Type | Description |
|---|---|
| Image<TPixel> | A new Image<TPixel>. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel format. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
Load<TPixel>(Configuration, ReadOnlySpan<Byte>, out IImageFormat)
Load a new instance of Image<TPixel> from the given encoded byte span.
Declaration
public static Image<TPixel> Load<TPixel>(Configuration configuration, ReadOnlySpan<byte> data, out IImageFormat format)
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The configuration options. |
| ReadOnlySpan<Byte> | data | The byte span containing image data. |
| IImageFormat | format | The IImageFormat of the decoded image. |
Returns
| Type | Description |
|---|---|
| Image<TPixel> | A new Image<TPixel>. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel format. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
Load<TPixel>(Configuration, String)
Create a new instance of the Image<TPixel> class from the given file.
Declaration
public static Image<TPixel> Load<TPixel>(Configuration configuration, string path)
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The configuration options. |
| String | path | The file path to the image. |
Returns
| Type | Description |
|---|---|
| Image<TPixel> | A new Image<TPixel>. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel format. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentNullException | The path is null. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
Load<TPixel>(Configuration, String, IImageDecoder)
Create a new instance of the Image<TPixel> class from the given file.
Declaration
public static Image<TPixel> Load<TPixel>(Configuration configuration, string path, IImageDecoder decoder)
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The Configuration. |
| String | path | The file path to the image. |
| IImageDecoder | decoder | The decoder. |
Returns
| Type | Description |
|---|---|
| Image<TPixel> | A new Image<TPixel>. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel format. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentNullException | The path is null. |
| ArgumentNullException | The decoder is null. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
Load<TPixel>(Configuration, String, out IImageFormat)
Create a new instance of the Image<TPixel> class from the given file.
Declaration
public static Image<TPixel> Load<TPixel>(Configuration configuration, string path, out IImageFormat format)
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The configuration options. |
| String | path | The file path to the image. |
| IImageFormat | format | The mime type of the decoded image. |
Returns
| Type | Description |
|---|---|
| Image<TPixel> | A new Image<TPixel>. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel format. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentNullException | The path is null. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
Load<TPixel>(Byte[])
Load a new instance of Image<TPixel> from the given encoded byte array.
Declaration
public static Image<TPixel> Load<TPixel>(byte[] data)
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| Byte[] | data | The byte array containing encoded image data. |
Returns
| Type | Description |
|---|---|
| Image<TPixel> | A new Image<TPixel>. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel format. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The data is null. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
Load<TPixel>(Byte[], IImageDecoder)
Load a new instance of Image<TPixel> from the given encoded byte array.
Declaration
public static Image<TPixel> Load<TPixel>(byte[] data, IImageDecoder decoder)
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| Byte[] | data | The byte array containing encoded image data. |
| IImageDecoder | decoder | The decoder. |
Returns
| Type | Description |
|---|---|
| Image<TPixel> | A new Image<TPixel>. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel format. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The data is null. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
Load<TPixel>(Byte[], out IImageFormat)
Load a new instance of Image<TPixel> from the given encoded byte array.
Declaration
public static Image<TPixel> Load<TPixel>(byte[] data, out IImageFormat format)
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| Byte[] | data | The byte array containing image data. |
| IImageFormat | format | The mime type of the decoded image. |
Returns
| Type | Description |
|---|---|
| Image<TPixel> | A new Image<TPixel>. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel format. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The data is null. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
Load<TPixel>(Stream)
Create a new instance of the Image<TPixel> class from the given stream.
Declaration
public static Image<TPixel> Load<TPixel>(Stream stream)
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream | The stream containing image information. |
Returns
| Type | Description |
|---|---|
| Image<TPixel> | A new Image<TPixel>. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel format. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The stream is null. |
| NotSupportedException | The stream is not readable. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
Load<TPixel>(Stream, IImageDecoder)
Create a new instance of the Image<TPixel> class from the given stream.
Declaration
public static Image<TPixel> Load<TPixel>(Stream stream, IImageDecoder decoder)
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream | The stream containing image information. |
| IImageDecoder | decoder | The decoder. |
Returns
| Type | Description |
|---|---|
| Image<TPixel> | A new Image<TPixel>. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel format. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The stream is null. |
| NotSupportedException | The stream is not readable. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
Load<TPixel>(Stream, out IImageFormat)
Create a new instance of the Image<TPixel> class from the given stream.
Declaration
public static Image<TPixel> Load<TPixel>(Stream stream, out IImageFormat format)
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream | The stream containing image information. |
| IImageFormat | format | The format type of the decoded image. |
Returns
| Type | Description |
|---|---|
| Image<TPixel> | A new Image<TPixel>. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel format. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The stream is null. |
| NotSupportedException | The stream is not readable. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
Load<TPixel>(ReadOnlySpan<Byte>)
Load a new instance of Image<TPixel> from the given encoded byte span.
Declaration
public static Image<TPixel> Load<TPixel>(ReadOnlySpan<byte> data)
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlySpan<Byte> | data | The byte span containing encoded image data. |
Returns
| Type | Description |
|---|---|
| Image<TPixel> | A new Image<TPixel>. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel format. |
Exceptions
| Type | Condition |
|---|---|
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
Load<TPixel>(ReadOnlySpan<Byte>, IImageDecoder)
Load a new instance of Image<TPixel> from the given encoded byte span.
Declaration
public static Image<TPixel> Load<TPixel>(ReadOnlySpan<byte> data, IImageDecoder decoder)
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlySpan<Byte> | data | The byte span containing encoded image data. |
| IImageDecoder | decoder | The decoder. |
Returns
| Type | Description |
|---|---|
| Image<TPixel> | A new Image<TPixel>. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel format. |
Exceptions
| Type | Condition |
|---|---|
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
Load<TPixel>(ReadOnlySpan<Byte>, out IImageFormat)
Load a new instance of Image<TPixel> from the given encoded byte span.
Declaration
public static Image<TPixel> Load<TPixel>(ReadOnlySpan<byte> data, out IImageFormat format)
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlySpan<Byte> | data | The byte span containing image data. |
| IImageFormat | format | The mime type of the decoded image. |
Returns
| Type | Description |
|---|---|
| Image<TPixel> | A new Image<TPixel>. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel format. |
Exceptions
| Type | Condition |
|---|---|
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
Load<TPixel>(String)
Create a new instance of the Image<TPixel> class from the given file.
Declaration
public static Image<TPixel> Load<TPixel>(string path)
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| String | path | The file path to the image. |
Returns
| Type | Description |
|---|---|
| Image<TPixel> | A new Image<TPixel>. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel format. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The path is null. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
Load<TPixel>(String, IImageDecoder)
Create a new instance of the Image<TPixel> class from the given file.
Declaration
public static Image<TPixel> Load<TPixel>(string path, IImageDecoder decoder)
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| String | path | The file path to the image. |
| IImageDecoder | decoder | The decoder. |
Returns
| Type | Description |
|---|---|
| Image<TPixel> | A new Image<TPixel>. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel format. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The path is null. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
Load<TPixel>(String, out IImageFormat)
Create a new instance of the Image<TPixel> class from the given file.
Declaration
public static Image<TPixel> Load<TPixel>(string path, out IImageFormat format)
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| String | path | The file path to the image. |
| IImageFormat | format | The mime type of the decoded image. |
Returns
| Type | Description |
|---|---|
| Image<TPixel> | A new Image<TPixel>. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel format. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The path is null. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
LoadAsync(Configuration, Stream, IImageDecoder, CancellationToken)
Decode a new instance of the Image class from the given stream. The pixel format is selected by the decoder.
Declaration
public static Task<Image> LoadAsync(Configuration configuration, Stream stream, IImageDecoder decoder, CancellationToken cancellationToken = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The configuration for the decoder. |
| Stream | stream | The stream containing image information. |
| IImageDecoder | decoder | The decoder. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task<Image> | A Task<TResult> representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentNullException | The stream is null. |
| ArgumentNullException | The decoder is null. |
| NotSupportedException | The stream is not readable. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
LoadAsync(Configuration, Stream, CancellationToken)
Decode a new instance of the Image class from the given stream.
Declaration
public static async Task<Image> LoadAsync(Configuration configuration, Stream stream, CancellationToken cancellationToken = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The configuration for the decoder. |
| Stream | stream | The stream containing image information. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task<Image> | A Task<TResult> representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentNullException | The stream is null. |
| NotSupportedException | The stream is not readable. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
LoadAsync(Configuration, String, IImageDecoder, CancellationToken)
Create a new instance of the Image class from the given file.
Declaration
public static Task<Image> LoadAsync(Configuration configuration, string path, IImageDecoder decoder, CancellationToken cancellationToken = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The Configuration. |
| String | path | The file path to the image. |
| IImageDecoder | decoder | The decoder. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task<Image> | A Task<TResult> representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentNullException | The path is null. |
| ArgumentNullException | The decoder is null. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
LoadAsync(Configuration, String, CancellationToken)
Create a new instance of the Image class from the given file.
Declaration
public static async Task<Image> LoadAsync(Configuration configuration, string path, CancellationToken cancellationToken = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The configuration for the decoder. |
| String | path | The file path to the image. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task<Image> | A Task<TResult> representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentNullException | The path is null. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
LoadAsync(Stream)
Decode a new instance of the Image class from the given stream. The pixel format is selected by the decoder.
Declaration
public static Task<Image> LoadAsync(Stream stream)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream | The stream containing image information. |
Returns
| Type | Description |
|---|---|
| Task<Image> | A Task<TResult> representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The stream is null. |
| NotSupportedException | The stream is not readable. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
LoadAsync(Stream, IImageDecoder)
Decode a new instance of the Image class from the given stream. The pixel format is selected by the decoder.
Declaration
public static Task<Image> LoadAsync(Stream stream, IImageDecoder decoder)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream | The stream containing image information. |
| IImageDecoder | decoder | The decoder. |
Returns
| Type | Description |
|---|---|
| Task<Image> | A Task<TResult> representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The stream is null. |
| ArgumentNullException | The decoder is null. |
| NotSupportedException | The stream is not readable. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
LoadAsync(String, IImageDecoder)
Create a new instance of the Image class from the given file.
Declaration
public static Task<Image> LoadAsync(string path, IImageDecoder decoder)
Parameters
| Type | Name | Description |
|---|---|---|
| String | path | The file path to the image. |
| IImageDecoder | decoder | The decoder. |
Returns
| Type | Description |
|---|---|
| Task<Image> | A Task<TResult> representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentNullException | The path is null. |
| ArgumentNullException | The decoder is null. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
LoadAsync(String, CancellationToken)
Create a new instance of the Image class from the given file.
Declaration
public static Task<Image> LoadAsync(string path, CancellationToken cancellationToken = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| String | path | The file path to the image. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task<Image> | A Task<TResult> representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentNullException | The path is null. |
| ArgumentNullException | The decoder is null. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
LoadAsync<TPixel>(Configuration, Stream, IImageDecoder, CancellationToken)
Create a new instance of the Image<TPixel> class from the given stream.
Declaration
public static Task<Image<TPixel>> LoadAsync<TPixel>(Configuration configuration, Stream stream, IImageDecoder decoder, CancellationToken cancellationToken = default(CancellationToken))
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The Configuration. |
| Stream | stream | The stream containing image information. |
| IImageDecoder | decoder | The decoder. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task<Image<TPixel>> | A Task representing the asynchronous operation. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel format. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentNullException | The stream is null. |
| NotSupportedException | The stream is not readable. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
LoadAsync<TPixel>(Configuration, Stream, CancellationToken)
Create a new instance of the Image<TPixel> class from the given stream.
Declaration
public static async Task<Image<TPixel>> LoadAsync<TPixel>(Configuration configuration, Stream stream, CancellationToken cancellationToken = default(CancellationToken))
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The configuration options. |
| Stream | stream | The stream containing image information. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task<Image<TPixel>> | A Task representing the asynchronous operation. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel format. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentNullException | The stream is null. |
| NotSupportedException | The stream is not readable. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
LoadAsync<TPixel>(Configuration, String, IImageDecoder, CancellationToken)
Create a new instance of the Image class from the given file.
Declaration
public static Task<Image<TPixel>> LoadAsync<TPixel>(Configuration configuration, string path, IImageDecoder decoder, CancellationToken cancellationToken = default(CancellationToken))
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The Configuration. |
| String | path | The file path to the image. |
| IImageDecoder | decoder | The decoder. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task<Image<TPixel>> | A Task<TResult> representing the asynchronous operation. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel format. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentNullException | The path is null. |
| ArgumentNullException | The decoder is null. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
LoadAsync<TPixel>(Configuration, String, CancellationToken)
Create a new instance of the Image class from the given file.
Declaration
public static async Task<Image<TPixel>> LoadAsync<TPixel>(Configuration configuration, string path, CancellationToken cancellationToken = default(CancellationToken))
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The configuration for the decoder. |
| String | path | The file path to the image. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task<Image<TPixel>> | A Task<TResult> representing the asynchronous operation. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel format. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentNullException | The path is null. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
LoadAsync<TPixel>(Stream)
Create a new instance of the Image<TPixel> class from the given stream.
Declaration
public static Task<Image<TPixel>> LoadAsync<TPixel>(Stream stream)
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream | The stream containing image information. |
Returns
| Type | Description |
|---|---|
| Task<Image<TPixel>> | A Task<TResult> representing the asynchronous operation. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel format. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The stream is null. |
| NotSupportedException | The stream is not readable. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
LoadAsync<TPixel>(Stream, IImageDecoder, CancellationToken)
Create a new instance of the Image<TPixel> class from the given stream.
Declaration
public static Task<Image<TPixel>> LoadAsync<TPixel>(Stream stream, IImageDecoder decoder, CancellationToken cancellationToken = default(CancellationToken))
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream | The stream containing image information. |
| IImageDecoder | decoder | The decoder. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task<Image<TPixel>> | A Task representing the asynchronous operation. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel format. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The stream is null. |
| NotSupportedException | The stream is not readable. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
LoadAsync<TPixel>(String)
Create a new instance of the Image class from the given file.
Declaration
public static Task<Image<TPixel>> LoadAsync<TPixel>(string path)
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| String | path | The file path to the image. |
Returns
| Type | Description |
|---|---|
| Task<Image<TPixel>> | A Task<TResult> representing the asynchronous operation. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel format. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentNullException | The path is null. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
LoadAsync<TPixel>(String, IImageDecoder)
Create a new instance of the Image class from the given file.
Declaration
public static Task<Image<TPixel>> LoadAsync<TPixel>(string path, IImageDecoder decoder)
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| String | path | The file path to the image. |
| IImageDecoder | decoder | The decoder. |
Returns
| Type | Description |
|---|---|
| Task<Image<TPixel>> | A Task<TResult> representing the asynchronous operation. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel format. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentNullException | The path is null. |
| ArgumentNullException | The decoder is null. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
LoadPixelData<TPixel>(TPixel[], Int32, Int32)
Create a new instance of the Image<TPixel> class from the raw TPixel data.
Declaration
public static Image<TPixel> LoadPixelData<TPixel>(TPixel[] data, int width, int height)
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| TPixel[] | data | The byte array containing image data. |
| Int32 | width | The width of the final image. |
| Int32 | height | The height of the final image. |
Returns
| Type | Description |
|---|---|
| Image<TPixel> | A new Image<TPixel>. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel format. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | The data length is incorrect. |
LoadPixelData<TPixel>(Configuration, TPixel[], Int32, Int32)
Create a new instance of the Image<TPixel> class from the raw TPixel data.
Declaration
public static Image<TPixel> LoadPixelData<TPixel>(Configuration configuration, TPixel[] data, int width, int height)
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The configuration for the decoder. |
| TPixel[] | data | The Span containing the image Pixel data. |
| Int32 | width | The width of the final image. |
| Int32 | height | The height of the final image. |
Returns
| Type | Description |
|---|---|
| Image<TPixel> | A new Image<TPixel>. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel format. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentException | The data length is incorrect. |
LoadPixelData<TPixel>(Configuration, Byte[], Int32, Int32)
Create a new instance of the Image<TPixel> class from the given byte array in TPixel format.
Declaration
public static Image<TPixel> LoadPixelData<TPixel>(Configuration configuration, byte[] data, int width, int height)
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The configuration for the decoder. |
| Byte[] | data | The byte array containing image data. |
| Int32 | width | The width of the final image. |
| Int32 | height | The height of the final image. |
Returns
| Type | Description |
|---|---|
| Image<TPixel> | A new Image<TPixel>. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel format. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentException | The data length is incorrect. |
LoadPixelData<TPixel>(Configuration, ReadOnlySpan<TPixel>, Int32, Int32)
Create a new instance of the Image<TPixel> class from the raw TPixel data.
Declaration
public static Image<TPixel> LoadPixelData<TPixel>(Configuration configuration, ReadOnlySpan<TPixel> data, int width, int height)
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The configuration for the decoder. |
| ReadOnlySpan<TPixel> | data | The Span containing the image Pixel data. |
| Int32 | width | The width of the final image. |
| Int32 | height | The height of the final image. |
Returns
| Type | Description |
|---|---|
| Image<TPixel> | A new Image<TPixel>. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel format. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentException | The data length is incorrect. |
LoadPixelData<TPixel>(Configuration, ReadOnlySpan<Byte>, Int32, Int32)
Create a new instance of the Image<TPixel> class from the given byte array in TPixel format.
Declaration
public static Image<TPixel> LoadPixelData<TPixel>(Configuration configuration, ReadOnlySpan<byte> data, int width, int height)
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The configuration for the decoder. |
| ReadOnlySpan<Byte> | data | The byte array containing image data. |
| Int32 | width | The width of the final image. |
| Int32 | height | The height of the final image. |
Returns
| Type | Description |
|---|---|
| Image<TPixel> | A new Image<TPixel>. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel format. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentException | The data length is incorrect. |
LoadPixelData<TPixel>(Byte[], Int32, Int32)
Create a new instance of the Image<TPixel> class from the given byte array in TPixel format.
Declaration
public static Image<TPixel> LoadPixelData<TPixel>(byte[] data, int width, int height)
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| Byte[] | data | The byte array containing image data. |
| Int32 | width | The width of the final image. |
| Int32 | height | The height of the final image. |
Returns
| Type | Description |
|---|---|
| Image<TPixel> | A new Image<TPixel>. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel format. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | The data length is incorrect. |
LoadPixelData<TPixel>(ReadOnlySpan<TPixel>, Int32, Int32)
Create a new instance of the Image<TPixel> class from the raw TPixel data.
Declaration
public static Image<TPixel> LoadPixelData<TPixel>(ReadOnlySpan<TPixel> data, int width, int height)
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlySpan<TPixel> | data | The byte array containing image data. |
| Int32 | width | The width of the final image. |
| Int32 | height | The height of the final image. |
Returns
| Type | Description |
|---|---|
| Image<TPixel> | A new Image<TPixel>. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel format. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | The data length is incorrect. |
LoadPixelData<TPixel>(ReadOnlySpan<Byte>, Int32, Int32)
Create a new instance of the Image<TPixel> class from the given byte array in TPixel format.
Declaration
public static Image<TPixel> LoadPixelData<TPixel>(ReadOnlySpan<byte> data, int width, int height)
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlySpan<Byte> | data | The byte array containing image data. |
| Int32 | width | The width of the final image. |
| Int32 | height | The height of the final image. |
Returns
| Type | Description |
|---|---|
| Image<TPixel> | A new Image<TPixel>. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel format. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | The data length is incorrect. |
LoadWithFormatAsync(Configuration, Stream, CancellationToken)
Create a new instance of the Image class from the given stream.
Declaration
public static async Task<(Image Image, IImageFormat Format)> LoadWithFormatAsync(Configuration configuration, Stream stream, CancellationToken cancellationToken = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The configuration options. |
| Stream | stream | The stream containing image information. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task<(T1, T2)<Image, IImageFormat>> | A Task<TResult> representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentNullException | The stream is null. |
| NotSupportedException | The stream is not readable. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
LoadWithFormatAsync(Stream)
Decode a new instance of the Image class from the given stream. The pixel format is selected by the decoder.
Declaration
public static Task<(Image Image, IImageFormat Format)> LoadWithFormatAsync(Stream stream)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream | The stream containing image information. |
Returns
| Type | Description |
|---|---|
| Task<(T1, T2)<Image, IImageFormat>> | A Task<TResult> representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The stream is null. |
| NotSupportedException | The stream is not readable. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
LoadWithFormatAsync<TPixel>(Configuration, Stream, CancellationToken)
Create a new instance of the Image<TPixel> class from the given stream.
Declaration
public static async Task<(Image<TPixel> Image, IImageFormat Format)> LoadWithFormatAsync<TPixel>(Configuration configuration, Stream stream, CancellationToken cancellationToken = default(CancellationToken))
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The configuration options. |
| Stream | stream | The stream containing image information. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task<(T1, T2)<Image<TPixel>, IImageFormat>> | A Task<TResult> representing the asynchronous operation. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel format. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentNullException | The stream is null. |
| NotSupportedException | The stream is not readable. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
LoadWithFormatAsync<TPixel>(Stream)
Create a new instance of the Image<TPixel> class from the given stream.
Declaration
public static Task<(Image<TPixel> Image, IImageFormat Format)> LoadWithFormatAsync<TPixel>(Stream stream)
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream | The stream containing image information. |
Returns
| Type | Description |
|---|---|
| Task<(T1, T2)<Image<TPixel>, IImageFormat>> | A Task<TResult> representing the asynchronous operation. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel format. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The stream is null. |
| NotSupportedException | The stream is not readable. |
| UnknownImageFormatException | Image format not recognised. |
| InvalidImageContentException | Image contains invalid content. |
Save(Stream, IImageEncoder)
Saves the image to the given stream using the given image encoder.
Declaration
public void Save(Stream stream, IImageEncoder encoder)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream | The stream to save the image to. |
| IImageEncoder | encoder | The encoder to save the image with. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the stream or encoder is null. |
SaveAsync(Stream, IImageEncoder, CancellationToken)
Saves the image to the given stream using the given image encoder.
Declaration
public Task SaveAsync(Stream stream, IImageEncoder encoder, CancellationToken cancellationToken = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream | The stream to save the image to. |
| IImageEncoder | encoder | The encoder to save the image with. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the stream or encoder is null. |
UpdateSize(Size)
Update the size of the image after mutation.
Declaration
protected void UpdateSize(Size size)
Parameters
| Type | Name | Description |
|---|---|---|
| Size | size | The Size. |
WrapMemory<TPixel>(Configuration, IMemoryOwner<TPixel>, Int32, Int32)
Wraps an existing contiguous memory area of at least 'width' x 'height' pixels,
allowing to view/manipulate it as an Image<TPixel> instance.
The ownership of the pixelMemoryOwner is being transferred to the new Image<TPixel> instance,
meaning that the caller is not allowed to dispose pixelMemoryOwner.
It will be disposed together with the result image.
Declaration
public static Image<TPixel> WrapMemory<TPixel>(Configuration configuration, IMemoryOwner<TPixel> pixelMemoryOwner, int width, int height)
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The Configuration |
| IMemoryOwner<TPixel> | pixelMemoryOwner | The IMemoryOwner<T> that is being transferred to the image. |
| Int32 | width | The width of the memory image. |
| Int32 | height | The height of the memory image. |
Returns
| Type | Description |
|---|---|
| Image<TPixel> | An Image<TPixel> instance |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel type. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
WrapMemory<TPixel>(Configuration, IMemoryOwner<TPixel>, Int32, Int32, ImageMetadata)
Wraps an existing contiguous memory area of at least 'width' x 'height' pixels,
allowing to view/manipulate it as an Image<TPixel> instance.
The ownership of the pixelMemoryOwner is being transferred to the new Image<TPixel> instance,
meaning that the caller is not allowed to dispose pixelMemoryOwner.
It will be disposed together with the result image.
Declaration
public static Image<TPixel> WrapMemory<TPixel>(Configuration configuration, IMemoryOwner<TPixel> pixelMemoryOwner, int width, int height, ImageMetadata metadata)
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The Configuration |
| IMemoryOwner<TPixel> | pixelMemoryOwner | The IMemoryOwner<T> that is being transferred to the image |
| Int32 | width | The width of the memory image. |
| Int32 | height | The height of the memory image. |
| ImageMetadata | metadata | The ImageMetadata |
Returns
| Type | Description |
|---|---|
| Image<TPixel> | An Image<TPixel> instance |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel type |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentNullException | The metadata is null. |
WrapMemory<TPixel>(Configuration, Memory<TPixel>, Int32, Int32)
Wraps an existing contiguous memory area of at least 'width' x 'height' pixels allowing viewing/manipulation as an Image<TPixel> instance.
Please note: using this method does not transfer the ownership of the underlying buffer of the input Memory<T> to the new Image<TPixel> instance. This means that consumers of this method must ensure that the input buffer is either self-contained, (for example, a Memory<T> instance wrapping a new array that was created), or that the owning object is not disposed until the returned Image<TPixel> is disposed.
If the input Memory<T> instance is one retrieved from an IMemoryOwner<T> instance rented from a memory pool (such as MemoryPool<T>), and that owning instance is disposed while the image is still in use, this will lead to undefined behavior and possibly runtime crashes (as the same buffer might then be modified by other consumers while the returned image is still working on it). Make sure to control the lifetime of the input buffers appropriately.
Declaration
public static Image<TPixel> WrapMemory<TPixel>(Configuration configuration, Memory<TPixel> pixelMemory, int width, int height)
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The Configuration |
| Memory<TPixel> | pixelMemory | The pixel memory. |
| Int32 | width | The width of the memory image. |
| Int32 | height | The height of the memory image. |
Returns
| Type | Description |
|---|---|
| Image<TPixel> | An Image<TPixel> instance. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel type |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
WrapMemory<TPixel>(Configuration, Memory<TPixel>, Int32, Int32, ImageMetadata)
Wraps an existing contiguous memory area of at least 'width' x 'height' pixels allowing viewing/manipulation as an Image<TPixel> instance.
Please note: using this method does not transfer the ownership of the underlying buffer of the input Memory<T> to the new Image<TPixel> instance. This means that consumers of this method must ensure that the input buffer is either self-contained, (for example, a Memory<T> instance wrapping a new array that was created), or that the owning object is not disposed until the returned Image<TPixel> is disposed.
If the input Memory<T> instance is one retrieved from an IMemoryOwner<T> instance rented from a memory pool (such as MemoryPool<T>), and that owning instance is disposed while the image is still in use, this will lead to undefined behavior and possibly runtime crashes (as the same buffer might then be modified by other consumers while the returned image is still working on it). Make sure to control the lifetime of the input buffers appropriately.
Declaration
public static Image<TPixel> WrapMemory<TPixel>(Configuration configuration, Memory<TPixel> pixelMemory, int width, int height, ImageMetadata metadata)
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The Configuration |
| Memory<TPixel> | pixelMemory | The pixel memory. |
| Int32 | width | The width of the memory image. |
| Int32 | height | The height of the memory image. |
| ImageMetadata | metadata | The ImageMetadata. |
Returns
| Type | Description |
|---|---|
| Image<TPixel> | An Image<TPixel> instance |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel type |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentNullException | The metadata is null. |
WrapMemory<TPixel>(Configuration, Memory<Byte>, Int32, Int32)
Wraps an existing contiguous memory area of at least 'width' x 'height' pixels allowing viewing/manipulation as an Image<TPixel> instance.
Please note: using this method does not transfer the ownership of the underlying buffer of the input Memory<T> to the new Image<TPixel> instance. This means that consumers of this method must ensure that the input buffer is either self-contained, (for example, a Memory<T> instance wrapping a new array that was created), or that the owning object is not disposed until the returned Image<TPixel> is disposed.
If the input Memory<T> instance is one retrieved from an IMemoryOwner<T> instance rented from a memory pool (such as MemoryPool<T>), and that owning instance is disposed while the image is still in use, this will lead to undefined behavior and possibly runtime crashes (as the same buffer might then be modified by other consumers while the returned image is still working on it). Make sure to control the lifetime of the input buffers appropriately.
Declaration
public static Image<TPixel> WrapMemory<TPixel>(Configuration configuration, Memory<byte> byteMemory, int width, int height)
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The Configuration |
| Memory<Byte> | byteMemory | The byte memory representing the pixel data. |
| Int32 | width | The width of the memory image. |
| Int32 | height | The height of the memory image. |
Returns
| Type | Description |
|---|---|
| Image<TPixel> | An Image<TPixel> instance. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel type |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
WrapMemory<TPixel>(Configuration, Memory<Byte>, Int32, Int32, ImageMetadata)
Wraps an existing contiguous memory area of at least 'width' x 'height' pixels allowing viewing/manipulation as an Image<TPixel> instance.
Please note: using this method does not transfer the ownership of the underlying buffer of the input Memory<T> to the new Image<TPixel> instance. This means that consumers of this method must ensure that the input buffer is either self-contained, (for example, a Memory<T> instance wrapping a new array that was created), or that the owning object is not disposed until the returned Image<TPixel> is disposed.
If the input Memory<T> instance is one retrieved from an IMemoryOwner<T> instance rented from a memory pool (such as MemoryPool<T>), and that owning instance is disposed while the image is still in use, this will lead to undefined behavior and possibly runtime crashes (as the same buffer might then be modified by other consumers while the returned image is still working on it). Make sure to control the lifetime of the input buffers appropriately.
Declaration
public static Image<TPixel> WrapMemory<TPixel>(Configuration configuration, Memory<byte> byteMemory, int width, int height, ImageMetadata metadata)
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The Configuration |
| Memory<Byte> | byteMemory | The byte memory representing the pixel data. |
| Int32 | width | The width of the memory image. |
| Int32 | height | The height of the memory image. |
| ImageMetadata | metadata | The ImageMetadata. |
Returns
| Type | Description |
|---|---|
| Image<TPixel> | An Image<TPixel> instance |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel type |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentNullException | The metadata is null. |
WrapMemory<TPixel>(Configuration, Void*, Int32, Int32)
Wraps an existing contiguous memory area of at least 'width' x 'height' pixels allowing viewing/manipulation as an Image<TPixel> instance.
Please note: this method relies on callers to carefully manage the target memory area being referenced by the pointer and that the lifetime of such a memory area is at least equal to that of the returned Image<TPixel> instance. For example, if the input pointer references an unmanaged memory area, callers must ensure that the memory area is not freed as long as the returned Image<TPixel> is in use and not disposed. The same applies if the input memory area points to a pinned managed object, as callers must ensure that objects will remain pinned as long as the Image<TPixel> instance is in use. Failing to do so constitutes undefined behavior and will likely lead to memory corruption and runtime crashes.
Note also that if you have a Memory<T> or an array (which can be cast to Memory<T>) of
either Byte or TPixel values, it is highly recommended to use one of the other
available overloads of this method instead (such as WrapMemory<TPixel>(Configuration, Memory<Byte>, Int32, Int32)
or WrapMemory<TPixel>(Configuration, Memory<TPixel>, Int32, Int32), to make the resulting code less error
prone and avoid having to pin the underlying memory buffer in use. This method is primarily meant to be used when
doing interop or working with buffers that are located in unmanaged memory.
Declaration
public static Image<TPixel> WrapMemory<TPixel>(Configuration configuration, void *pointer, int width, int height)
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The Configuration |
| Void* | pointer | The pointer to the target memory buffer to wrap. |
| Int32 | width | The width of the memory image. |
| Int32 | height | The height of the memory image. |
Returns
| Type | Description |
|---|---|
| Image<TPixel> | An Image<TPixel> instance. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel type |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
WrapMemory<TPixel>(Configuration, Void*, Int32, Int32, ImageMetadata)
Wraps an existing contiguous memory area of at least 'width' x 'height' pixels allowing viewing/manipulation as an Image<TPixel> instance.
Please note: this method relies on callers to carefully manage the target memory area being referenced by the pointer and that the lifetime of such a memory area is at least equal to that of the returned Image<TPixel> instance. For example, if the input pointer references an unmanaged memory area, callers must ensure that the memory area is not freed as long as the returned Image<TPixel> is in use and not disposed. The same applies if the input memory area points to a pinned managed object, as callers must ensure that objects will remain pinned as long as the Image<TPixel> instance is in use. Failing to do so constitutes undefined behavior and will likely lead to memory corruption and runtime crashes.
Note also that if you have a Memory<T> or an array (which can be cast to Memory<T>) of
either Byte or TPixel values, it is highly recommended to use one of the other
available overloads of this method instead (such as WrapMemory<TPixel>(Configuration, Memory<Byte>, Int32, Int32)
or WrapMemory<TPixel>(Configuration, Memory<TPixel>, Int32, Int32), to make the resulting code less error
prone and avoid having to pin the underlying memory buffer in use. This method is primarily meant to be used when
doing interop or working with buffers that are located in unmanaged memory.
Declaration
public static Image<TPixel> WrapMemory<TPixel>(Configuration configuration, void *pointer, int width, int height, ImageMetadata metadata)
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The Configuration |
| Void* | pointer | The pointer to the target memory buffer to wrap. |
| Int32 | width | The width of the memory image. |
| Int32 | height | The height of the memory image. |
| ImageMetadata | metadata | The ImageMetadata. |
Returns
| Type | Description |
|---|---|
| Image<TPixel> | An Image<TPixel> instance |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel type |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The configuration is null. |
| ArgumentNullException | The metadata is null. |
WrapMemory<TPixel>(IMemoryOwner<TPixel>, Int32, Int32)
Wraps an existing contiguous memory area of at least 'width' x 'height' pixels,
allowing to view/manipulate it as an Image<TPixel> instance.
The ownership of the pixelMemoryOwner is being transferred to the new Image<TPixel> instance,
meaning that the caller is not allowed to dispose pixelMemoryOwner.
It will be disposed together with the result image.
Declaration
public static Image<TPixel> WrapMemory<TPixel>(IMemoryOwner<TPixel> pixelMemoryOwner, int width, int height)
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| IMemoryOwner<TPixel> | pixelMemoryOwner | The IMemoryOwner<T> that is being transferred to the image. |
| Int32 | width | The width of the memory image. |
| Int32 | height | The height of the memory image. |
Returns
| Type | Description |
|---|---|
| Image<TPixel> | An Image<TPixel> instance. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel type |
WrapMemory<TPixel>(Memory<TPixel>, Int32, Int32)
Wraps an existing contiguous memory area of at least 'width' x 'height' pixels allowing viewing/manipulation as an Image<TPixel> instance.
Please note: using this method does not transfer the ownership of the underlying buffer of the input Memory<T> to the new Image<TPixel> instance. This means that consumers of this method must ensure that the input buffer is either self-contained, (for example, a Memory<T> instance wrapping a new array that was created), or that the owning object is not disposed until the returned Image<TPixel> is disposed.
If the input Memory<T> instance is one retrieved from an IMemoryOwner<T> instance rented from a memory pool (such as MemoryPool<T>), and that owning instance is disposed while the image is still in use, this will lead to undefined behavior and possibly runtime crashes (as the same buffer might then be modified by other consumers while the returned image is still working on it). Make sure to control the lifetime of the input buffers appropriately.
Declaration
public static Image<TPixel> WrapMemory<TPixel>(Memory<TPixel> pixelMemory, int width, int height)
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| Memory<TPixel> | pixelMemory | The pixel memory. |
| Int32 | width | The width of the memory image. |
| Int32 | height | The height of the memory image. |
Returns
| Type | Description |
|---|---|
| Image<TPixel> | An Image<TPixel> instance. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel type. |
WrapMemory<TPixel>(Memory<Byte>, Int32, Int32)
Wraps an existing contiguous memory area of at least 'width' x 'height' pixels allowing viewing/manipulation as an Image<TPixel> instance.
Please note: using this method does not transfer the ownership of the underlying buffer of the input Memory<T> to the new Image<TPixel> instance. This means that consumers of this method must ensure that the input buffer is either self-contained, (for example, a Memory<T> instance wrapping a new array that was created), or that the owning object is not disposed until the returned Image<TPixel> is disposed.
If the input Memory<T> instance is one retrieved from an IMemoryOwner<T> instance rented from a memory pool (such as MemoryPool<T>), and that owning instance is disposed while the image is still in use, this will lead to undefined behavior and possibly runtime crashes (as the same buffer might then be modified by other consumers while the returned image is still working on it). Make sure to control the lifetime of the input buffers appropriately.
Declaration
public static Image<TPixel> WrapMemory<TPixel>(Memory<byte> byteMemory, int width, int height)
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| Memory<Byte> | byteMemory | The byte memory representing the pixel data. |
| Int32 | width | The width of the memory image. |
| Int32 | height | The height of the memory image. |
Returns
| Type | Description |
|---|---|
| Image<TPixel> | An Image<TPixel> instance. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel type. |
WrapMemory<TPixel>(Void*, Int32, Int32)
Wraps an existing contiguous memory area of at least 'width' x 'height' pixels allowing viewing/manipulation as an Image<TPixel> instance.
Please note: this method relies on callers to carefully manage the target memory area being referenced by the pointer and that the lifetime of such a memory area is at least equal to that of the returned Image<TPixel> instance. For example, if the input pointer references an unmanaged memory area, callers must ensure that the memory area is not freed as long as the returned Image<TPixel> is in use and not disposed. The same applies if the input memory area points to a pinned managed object, as callers must ensure that objects will remain pinned as long as the Image<TPixel> instance is in use. Failing to do so constitutes undefined behavior and will likely lead to memory corruption and runtime crashes.
Note also that if you have a Memory<T> or an array (which can be cast to Memory<T>) of
either Byte or TPixel values, it is highly recommended to use one of the other
available overloads of this method instead (such as WrapMemory<TPixel>(Configuration, Memory<Byte>, Int32, Int32)
or WrapMemory<TPixel>(Configuration, Memory<TPixel>, Int32, Int32), to make the resulting code less error
prone and avoid having to pin the underlying memory buffer in use. This method is primarily meant to be used when
doing interop or working with buffers that are located in unmanaged memory.
Declaration
public static Image<TPixel> WrapMemory<TPixel>(void *pointer, int width, int height)
where TPixel : struct, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| Void* | pointer | The pointer to the target memory buffer to wrap. |
| Int32 | width | The width of the memory image. |
| Int32 | height | The height of the memory image. |
Returns
| Type | Description |
|---|---|
| Image<TPixel> | An Image<TPixel> instance. |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel type. |