Struct OctreeQuantizer<TPixel>
Encapsulates methods to calculate the color palette if an image using an Octree pattern. http://msdn.microsoft.com/en-us/library/aa479306.aspx
Inherited Members
Namespace: SixLabors.ImageSharp.Processing.Processors.Quantization
Assembly: SixLabors.ImageSharp.dll
Syntax
public struct OctreeQuantizer<TPixel> : IQuantizer<TPixel>, IDisposable where TPixel : struct, IPixel<TPixel>
Type Parameters
| Name | Description |
|---|---|
| TPixel | The pixel format. |
Constructors
| Improve this Doc View SourceOctreeQuantizer(Configuration, QuantizerOptions)
Initializes a new instance of the OctreeQuantizer<TPixel> struct.
Declaration
public OctreeQuantizer(Configuration configuration, QuantizerOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| Configuration | configuration | The configuration which allows altering default behaviour or extending the library. |
| QuantizerOptions | options | The quantizer options defining quantization rules. |
Properties
| Improve this Doc View SourceConfiguration
Gets the configuration.
Declaration
public readonly Configuration Configuration { get; }
Property Value
| Type | Description |
|---|---|
| Configuration |
Options
Gets the quantizer options defining quantization rules.
Declaration
public readonly QuantizerOptions Options { get; }
Property Value
| Type | Description |
|---|---|
| QuantizerOptions |
Palette
Gets the quantized color palette.
Declaration
public readonly 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
public void AddPaletteColors(Buffer2DRegion<TPixel> pixelRegion)
Parameters
| Type | Name | Description |
|---|---|---|
| Buffer2DRegion<TPixel> | pixelRegion | The Buffer2DRegion<T> of source pixels to register. |
Dispose()
Declaration
public void Dispose()
GetQuantizedColor(TPixel, out TPixel)
Returns the index and color from the quantized palette corresponding to the given color.
Declaration
public readonly 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
public readonly 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).