Class AdvancedImageExtensions
Extension methods over Image{TPixel}
Inherited Members
Namespace: SixLabors.ImageSharp.Advanced
Assembly: SixLabors.ImageSharp.dll
Syntax
public static class AdvancedImageExtensions
Methods
| Edit this page 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)
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>(ImageFrame<TPixel>, int)
Gets the representation of the pixels as a Span<T> of contiguous memory
at row rowIndex beginning from the first pixel on that row.
Declaration
public static Memory<TPixel> DangerousGetPixelRowMemory<TPixel>(this ImageFrame<TPixel> source, int rowIndex) where TPixel : unmanaged, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| ImageFrame<TPixel> | source | The source. |
| int | rowIndex | The row. |
Returns
| Type | Description |
|---|---|
| Memory<TPixel> | The Span<T> |
Type Parameters
| Name | Description |
|---|---|
| TPixel | The type of the pixel. |
DangerousGetPixelRowMemory<TPixel>(Image<TPixel>, int)
Gets the representation of the pixels as Span<T> of contiguous memory
at row rowIndex beginning from the first pixel on that row.
Declaration
public static Memory<TPixel> DangerousGetPixelRowMemory<TPixel>(this Image<TPixel> source, int rowIndex) where TPixel : unmanaged, IPixel<TPixel>
Parameters
| Type | Name | Description |
|---|---|---|
| Image<TPixel> | source | The source. |
| int | 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. |
| UnknownImageFormatException | No encoder available for provided path. |
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 : unmanaged, 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>.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown when the |
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 : unmanaged, 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>.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown when the |