Class QuantizerUtilities
- Namespace
- SixLabors.ImageSharp.Processing.Processors.Quantization
- Assembly
- SixLabors.ImageSharp.dll
Contains utility methods for IQuantizer<TPixel> instances.
public static class QuantizerUtilities
- Inheritance
-
QuantizerUtilities
- Inherited Members
Methods
BuildPaletteAndQuantizeFrame<TPixel>(IQuantizer<TPixel>, ImageFrame<TPixel>, Rectangle)
Execute both steps of the quantization.
public static IndexedImageFrame<TPixel> BuildPaletteAndQuantizeFrame<TPixel>(this IQuantizer<TPixel> quantizer, ImageFrame<TPixel> source, Rectangle bounds) where TPixel : unmanaged, IPixel<TPixel>
Parameters
quantizer
IQuantizer<TPixel>The pixel specific quantizer.
source
ImageFrame<TPixel>The source image frame to quantize.
bounds
RectangleThe bounds within the frame to quantize.
Returns
- IndexedImageFrame<TPixel>
A IndexedImageFrame<TPixel> representing a quantized version of the source frame pixels.
Type Parameters
TPixel
The pixel type.
BuildPalette<TPixel>(IQuantizer<TPixel>, IPixelSamplingStrategy, ImageFrame<TPixel>)
Adds colors to the quantized palette from the given pixel regions.
public static void BuildPalette<TPixel>(this IQuantizer<TPixel> quantizer, IPixelSamplingStrategy pixelSamplingStrategy, ImageFrame<TPixel> source) where TPixel : unmanaged, IPixel<TPixel>
Parameters
quantizer
IQuantizer<TPixel>The pixel specific quantizer.
pixelSamplingStrategy
IPixelSamplingStrategyThe pixel sampling strategy.
source
ImageFrame<TPixel>The source image frame to sample from.
Type Parameters
TPixel
The pixel format.
BuildPalette<TPixel>(IQuantizer<TPixel>, IPixelSamplingStrategy, Image<TPixel>)
Adds colors to the quantized palette from the given pixel regions.
public static void BuildPalette<TPixel>(this IQuantizer<TPixel> quantizer, IPixelSamplingStrategy pixelSamplingStrategy, Image<TPixel> source) where TPixel : unmanaged, IPixel<TPixel>
Parameters
quantizer
IQuantizer<TPixel>The pixel specific quantizer.
pixelSamplingStrategy
IPixelSamplingStrategyThe pixel sampling strategy.
source
Image<TPixel>The source image to sample from.
Type Parameters
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.
public static void CheckPaletteState<TPixel>(in ReadOnlyMemory<TPixel> palette) where TPixel : unmanaged, IPixel<TPixel>
Parameters
palette
ReadOnlyMemory<TPixel>The frame quantizer palette.
Type Parameters
TPixel
The pixel format.
Exceptions
- 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.
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
quantizer
TFrameQuantizerThe pixel specific quantizer.
source
ImageFrame<TPixel>The source image frame to quantize.
bounds
RectangleThe bounds within the frame to quantize.
Returns
- IndexedImageFrame<TPixel>
A IndexedImageFrame<TPixel> representing a quantized version of the source frame pixels.
Type Parameters
TFrameQuantizer
The type of frame quantizer.
TPixel
The pixel format.