Class QuantizerUtilities
Contains utility methods for IQuantizer<TPixel> instances.
Inherited Members
Namespace: SixLabors.ImageSharp.Processing.Processors.Quantization
Assembly: SixLabors.ImageSharp.dll
Syntax
public static class QuantizerUtilities
Methods
| Edit this page View SourceBuildPaletteAndQuantizeFrame<TPixel>(IQuantizer<TPixel>, ImageFrame<TPixel>, Rectangle)
Execute both steps of the quantization.
Declaration
public static IndexedImageFrame<TPixel> BuildPaletteAndQuantizeFrame<TPixel>(this IQuantizer<TPixel> quantizer, ImageFrame<TPixel> source, Rectangle bounds) where TPixel : unmanaged, IPixel<TPixel>
Parameters
Type | Name | Description |
---|---|---|
IQuantizer<TPixel> | quantizer | The pixel specific quantizer. |
ImageFrame<TPixel> | source | The source image frame to quantize. |
Rectangle | bounds | The bounds within the frame to quantize. |
Returns
Type | Description |
---|---|
IndexedImageFrame<TPixel> | A IndexedImageFrame<TPixel> representing a quantized version of the source frame pixels. |
Type Parameters
Name | Description |
---|---|
TPixel | The pixel type. |
BuildPalette<TPixel>(IQuantizer<TPixel>, IPixelSamplingStrategy, ImageFrame<TPixel>)
Adds colors to the quantized palette from the given pixel regions.
Declaration
public static void BuildPalette<TPixel>(this IQuantizer<TPixel> quantizer, IPixelSamplingStrategy pixelSamplingStrategy, ImageFrame<TPixel> source) where TPixel : unmanaged, IPixel<TPixel>
Parameters
Type | Name | Description |
---|---|---|
IQuantizer<TPixel> | quantizer | The pixel specific quantizer. |
IPixelSamplingStrategy | pixelSamplingStrategy | The pixel sampling strategy. |
ImageFrame<TPixel> | source | The source image frame to sample from. |
Type Parameters
Name | Description |
---|---|
TPixel | The pixel format. |
BuildPalette<TPixel>(IQuantizer<TPixel>, IPixelSamplingStrategy, Image<TPixel>)
Adds colors to the quantized palette from the given pixel regions.
Declaration
public static void BuildPalette<TPixel>(this IQuantizer<TPixel> quantizer, IPixelSamplingStrategy pixelSamplingStrategy, Image<TPixel> source) where TPixel : unmanaged, IPixel<TPixel>
Parameters
Type | Name | Description |
---|---|---|
IQuantizer<TPixel> | quantizer | The pixel specific quantizer. |
IPixelSamplingStrategy | pixelSamplingStrategy | The pixel sampling strategy. |
Image<TPixel> | source | The source image to sample from. |
Type Parameters
Name | Description |
---|---|
TPixel | The pixel format. |
CheckPaletteState<TPixel>(in ReadOnlyMemory<TPixel>)
Helper method for throwing an exception when a frame quantizer palette has been requested but not built yet.
Declaration
public static void CheckPaletteState<TPixel>(in ReadOnlyMemory<TPixel> palette) where TPixel : unmanaged, IPixel<TPixel>
Parameters
Type | Name | Description |
---|---|---|
ReadOnlyMemory<TPixel> | palette | The frame quantizer palette. |
Type Parameters
Name | Description |
---|---|
TPixel | The pixel format. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | The palette has not been built via AddPaletteColors(Buffer2DRegion<TPixel>) |
QuantizeFrame<TFrameQuantizer, TPixel>(ref TFrameQuantizer, ImageFrame<TPixel>, Rectangle)
Quantizes an image frame and return the resulting output pixels.
Declaration
public static IndexedImageFrame<TPixel> QuantizeFrame<TFrameQuantizer, TPixel>(ref TFrameQuantizer quantizer, ImageFrame<TPixel> source, Rectangle bounds) where TFrameQuantizer : struct, IQuantizer<TPixel> where TPixel : unmanaged, IPixel<TPixel>
Parameters
Type | Name | Description |
---|---|---|
TFrameQuantizer | quantizer | The pixel specific quantizer. |
ImageFrame<TPixel> | source | The source image frame to quantize. |
Rectangle | bounds | The bounds within the frame to quantize. |
Returns
Type | Description |
---|---|
IndexedImageFrame<TPixel> | A IndexedImageFrame<TPixel> representing a quantized version of the source frame pixels. |
Type Parameters
Name | Description |
---|---|
TFrameQuantizer | The type of frame quantizer. |
TPixel | The pixel format. |