Table of Contents

Class AdvancedImageExtensions

Namespace
SixLabors.ImageSharp.Advanced
Assembly
SixLabors.ImageSharp.dll

Extension methods over Image{TPixel}

public static class AdvancedImageExtensions
Inheritance
AdvancedImageExtensions
Inherited Members

Methods

AcceptVisitor(Image, IImageVisitor)

Accepts a IImageVisitor to implement a double-dispatch pattern in order to apply pixel-specific operations on non-generic Image instances

public static void AcceptVisitor(this Image source, IImageVisitor visitor)

Parameters

source Image

The source image.

visitor IImageVisitor

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

public static Task AcceptVisitorAsync(this Image source, IImageVisitorAsync visitor, CancellationToken cancellationToken = default)

Parameters

source Image

The source image.

visitor IImageVisitorAsync

The image visitor.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

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.

public static Memory<TPixel> DangerousGetPixelRowMemory<TPixel>(this ImageFrame<TPixel> source, int rowIndex) where TPixel : unmanaged, IPixel<TPixel>

Parameters

source ImageFrame<TPixel>

The source.

rowIndex int

The row.

Returns

Memory<TPixel>

The Span<T>

Type Parameters

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.

public static Memory<TPixel> DangerousGetPixelRowMemory<TPixel>(this Image<TPixel> source, int rowIndex) where TPixel : unmanaged, IPixel<TPixel>

Parameters

source Image<TPixel>

The source.

rowIndex int

The row.

Returns

Memory<TPixel>

The Span<T>

Type Parameters

TPixel

The type of the pixel.

DetectEncoder(Image, string)

For a given file path find the best encoder to use via its extension.

public static IImageEncoder DetectEncoder(this Image source, string filePath)

Parameters

source Image

The source image.

filePath string

The target file path to save the image to.

Returns

IImageEncoder

The matching IImageEncoder.

Exceptions

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.

public static IMemoryGroup<TPixel> GetPixelMemoryGroup<TPixel>(this ImageFrame<TPixel> source) where TPixel : unmanaged, IPixel<TPixel>

Parameters

source ImageFrame<TPixel>

The source image.

Returns

IMemoryGroup<TPixel>

The IMemoryGroup<T>.

Type Parameters

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

ArgumentNullException

Thrown when the source in null.

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.

public static IMemoryGroup<TPixel> GetPixelMemoryGroup<TPixel>(this Image<TPixel> source) where TPixel : unmanaged, IPixel<TPixel>

Parameters

source Image<TPixel>

The source image.

Returns

IMemoryGroup<TPixel>

The IMemoryGroup<T>.

Type Parameters

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

ArgumentNullException

Thrown when the source in null.