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