Class AdvancedImageExtensions
Extension methods over Image{TPixel}
Inherited Members
Namespace: SixLabors.ImageSharp.Advanced
Assembly: SixLabors.ImageSharp.dll
Syntax
public static class AdvancedImageExtensions
Methods
| Improve this Doc View SourceAcceptVisitor(Image, IImageVisitor)
Accepts a IImageVisitor to implement a double-dispatch pattern in order to apply pixel-specific operations on non-generic Image instances
Declaration
public static void AcceptVisitor(this Image source, IImageVisitor visitor)
Parameters
Type | Name | Description |
---|---|---|
Image | source | The source image. |
IImageVisitor | visitor | The image visitor. |
AcceptVisitorAsync(Image, IImageVisitorAsync, CancellationToken)
Accepts a IImageVisitor to implement a double-dispatch pattern in order to apply pixel-specific operations on non-generic Image instances
Declaration
public static Task AcceptVisitorAsync(this Image source, IImageVisitorAsync visitor, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Image | source | The source image. |
IImageVisitorAsync | visitor | The image visitor. |
CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
Type | Description |
---|---|
Task | A Task representing the asynchronous operation. |
DangerousGetPixelRowMemory<TPixel>(Image<TPixel>, Int32)
Gets the representation of the pixels as Span<T> of of contiguous memory
at row rowIndex
beginning from the the first pixel on that row.
Declaration
public static Memory<TPixel> DangerousGetPixelRowMemory<TPixel>(this Image<TPixel> source, int rowIndex)
where TPixel : struct, IPixel<TPixel>
Parameters
Type | Name | Description |
---|---|---|
Image<TPixel> | source | The source. |
Int32 | rowIndex | The row. |
Returns
Type | Description |
---|---|
Memory<TPixel> | The Span<T> |
Type Parameters
Name | Description |
---|---|
TPixel | The type of the pixel. |
DangerousGetPixelRowMemory<TPixel>(ImageFrame<TPixel>, Int32)
Gets the representation of the pixels as a Span<T> of contiguous memory
at row rowIndex
beginning from the the first pixel on that row.
Declaration
public static Memory<TPixel> DangerousGetPixelRowMemory<TPixel>(this ImageFrame<TPixel> source, int rowIndex)
where TPixel : struct, IPixel<TPixel>
Parameters
Type | Name | Description |
---|---|---|
ImageFrame<TPixel> | source | The source. |
Int32 | rowIndex | The row. |
Returns
Type | Description |
---|---|
Memory<TPixel> | The Span<T> |
Type Parameters
Name | Description |
---|---|
TPixel | The type of the pixel. |
DetectEncoder(Image, String)
For a given file path find the best encoder to use via its extension.
Declaration
public static IImageEncoder DetectEncoder(this Image source, string filePath)
Parameters
Type | Name | Description |
---|---|---|
Image | source | The source image. |
String | filePath | The target file path to save the image to. |
Returns
Type | Description |
---|---|
IImageEncoder | The matching IImageEncoder. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | The file path is null. |
NotSupportedException | No encoder available for provided path. |
GetConfiguration(Image)
Gets the configuration for the image.
Declaration
public static Configuration GetConfiguration(this Image source)
Parameters
Type | Name | Description |
---|---|---|
Image | source | The source image. |
Returns
Type | Description |
---|---|
Configuration | Returns the configuration. |
GetConfiguration(ImageFrame)
Gets the configuration for the image frame.
Declaration
public static Configuration GetConfiguration(this ImageFrame source)
Parameters
Type | Name | Description |
---|---|---|
ImageFrame | source | The source image. |
Returns
Type | Description |
---|---|
Configuration | Returns the configuration. |
GetPixelMemoryGroup<TPixel>(Image<TPixel>)
Gets the representation of the pixels as a IMemoryGroup<T> containing the backing pixel data of the image stored in row major order, as a list of contiguous Memory<T> blocks in the source image's pixel format.
Declaration
public static IMemoryGroup<TPixel> GetPixelMemoryGroup<TPixel>(this Image<TPixel> source)
where TPixel : struct, IPixel<TPixel>
Parameters
Type | Name | Description |
---|---|---|
Image<TPixel> | source | The source image. |
Returns
Type | Description |
---|---|
IMemoryGroup<TPixel> | The IMemoryGroup<T>. |
Type Parameters
Name | Description |
---|---|
TPixel | The type of the pixel. |
Remarks
Certain Image Processors may invalidate the returned IMemoryGroup<T> and all it's buffers, therefore it's not recommended to mutate the image while holding a reference to it's IMemoryGroup<T>.
GetPixelMemoryGroup<TPixel>(ImageFrame<TPixel>)
Gets the representation of the pixels as a IMemoryGroup<T> containing the backing pixel data of the image stored in row major order, as a list of contiguous Memory<T> blocks in the source image's pixel format.
Declaration
public static IMemoryGroup<TPixel> GetPixelMemoryGroup<TPixel>(this ImageFrame<TPixel> source)
where TPixel : struct, IPixel<TPixel>
Parameters
Type | Name | Description |
---|---|---|
ImageFrame<TPixel> | source | The source image. |
Returns
Type | Description |
---|---|
IMemoryGroup<TPixel> | The IMemoryGroup<T>. |
Type Parameters
Name | Description |
---|---|
TPixel | The type of the pixel. |
Remarks
Certain Image Processors may invalidate the returned IMemoryGroup<T> and all it's buffers, therefore it's not recommended to mutate the image while holding a reference to it's IMemoryGroup<T>.