Interface IQuantizer<TPixel>
- Namespace
- SixLabors.ImageSharp.Processing.Processors.Quantization
- Assembly
- SixLabors.ImageSharp.dll
Provides methods to allow the execution of the quantization process on an image frame.
public interface IQuantizer<TPixel> : IDisposable where TPixel : unmanaged, IPixel<TPixel>
Type Parameters
TPixel
The pixel format.
- Inherited Members
- Extension Methods
Properties
Configuration
Gets the configuration.
Configuration Configuration { get; }
Property Value
Options
Gets the quantizer options defining quantization rules.
QuantizerOptions Options { get; }
Property Value
Palette
Gets the quantized color palette.
ReadOnlyMemory<TPixel> Palette { get; }
Property Value
- ReadOnlyMemory<TPixel>
Exceptions
- InvalidOperationException
The palette has not been built via AddPaletteColors(Buffer2DRegion<TPixel>).
Methods
AddPaletteColors(Buffer2DRegion<TPixel>)
Adds colors to the quantized palette from the given pixel source.
void AddPaletteColors(Buffer2DRegion<TPixel> pixelRegion)
Parameters
pixelRegion
Buffer2DRegion<TPixel>The Buffer2DRegion<T> of source pixels to register.
GetQuantizedColor(TPixel, out TPixel)
Returns the index and color from the quantized palette corresponding to the given color.
byte GetQuantizedColor(TPixel color, out TPixel match)
Parameters
color
TPixelThe color to match.
match
TPixelThe matched color.
Returns
QuantizeFrame(ImageFrame<TPixel>, Rectangle)
Quantizes an image frame and return the resulting output pixels.
IndexedImageFrame<TPixel> QuantizeFrame(ImageFrame<TPixel> source, Rectangle bounds)
Parameters
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.
Remarks
Only executes the second (quantization) step. The palette has to be built by calling AddPaletteColors(Buffer2DRegion<TPixel>). To run both steps, use BuildPaletteAndQuantizeFrame<TPixel>(IQuantizer<TPixel>, ImageFrame<TPixel>, Rectangle).