Interface IQuantizer<TPixel>
Provides methods to allow the execution of the quantization process on an image frame.
Inherited Members
Namespace: SixLabors.ImageSharp.Processing.Processors.Quantization
Assembly: SixLabors.ImageSharp.dll
Syntax
public interface IQuantizer<TPixel> : IDisposable where TPixel : struct, IPixel<TPixel>
Type Parameters
Name | Description |
---|---|
TPixel | The pixel format. |
Properties
| Improve this Doc View SourceConfiguration
Gets the configuration.
Declaration
Configuration Configuration { get; }
Property Value
Type | Description |
---|---|
Configuration |
Options
Gets the quantizer options defining quantization rules.
Declaration
QuantizerOptions Options { get; }
Property Value
Type | Description |
---|---|
QuantizerOptions |
Palette
Gets the quantized color palette.
Declaration
ReadOnlyMemory<TPixel> Palette { get; }
Property Value
Type | Description |
---|---|
ReadOnlyMemory<TPixel> |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | The palette has not been built via AddPaletteColors(Buffer2DRegion<TPixel>). |
Methods
| Improve this Doc View SourceAddPaletteColors(Buffer2DRegion<TPixel>)
Adds colors to the quantized palette from the given pixel source.
Declaration
void AddPaletteColors(Buffer2DRegion<TPixel> pixelRegion)
Parameters
Type | Name | Description |
---|---|---|
Buffer2DRegion<TPixel> | pixelRegion | 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.
Declaration
byte GetQuantizedColor(TPixel color, out TPixel match)
Parameters
Type | Name | Description |
---|---|---|
TPixel | color | The color to match. |
TPixel | match | The matched color. |
Returns
Type | Description |
---|---|
Byte | The Byte index. |
QuantizeFrame(ImageFrame<TPixel>, Rectangle)
Quantizes an image frame and return the resulting output pixels.
Declaration
IndexedImageFrame<TPixel> QuantizeFrame(ImageFrame<TPixel> source, Rectangle bounds)
Parameters
Type | Name | Description |
---|---|---|
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. |
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).