Class Quantizer
Abstarct class for Quantizers.
Namespace: DotNetNuke.Services.GeneratedImage.ImageQuantization
Assembly: DotNetNuke.dll
Syntax
public abstract class Quantizer : object
Constructors
| Improve this Doc View SourceQuantizer(Boolean)
Initializes a new instance of the Quantizer class. Construct the quantizer.
Declaration
public Quantizer(bool singlePass)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | singlePass | If true, the quantization only needs to loop through the source pixels once. |
Remarks
If you construct this class with a true value for singlePass, then the code will, when quantizing your image, only call the 'QuantizeImage' function. If two passes are required, the code will call 'InitialQuantizeImage' and then 'QuantizeImage'.
Methods
| Improve this Doc View SourceFirstPass(BitmapData, Int32, Int32)
Execute the first pass through the pixels in the image.
Declaration
protected virtual void FirstPass(BitmapData sourceData, int width, int height)
Parameters
| Type | Name | Description |
|---|---|---|
| BitmapData | sourceData | The source data. |
| System.Int32 | width | The width in pixels of the image. |
| System.Int32 | height | The height in pixels of the image. |
GetPalette(ColorPalette)
Retrieve the palette for the quantized image.
Declaration
protected abstract ColorPalette GetPalette(ColorPalette original)
Parameters
| Type | Name | Description |
|---|---|---|
| ColorPalette | original | Any old palette, this is overrwritten. |
Returns
| Type | Description |
|---|---|
| ColorPalette | The new color palette. |
InitialQuantizePixel(Quantizer.Color32)
Override this to process the pixel in the first pass of the algorithm.
Declaration
protected virtual void InitialQuantizePixel(Quantizer.Color32 pixel)
Parameters
| Type | Name | Description |
|---|---|---|
| Quantizer.Color32 | pixel | The pixel to quantize. |
Remarks
This function need only be overridden if your quantize algorithm needs two passes, such as an Octree quantizer.
Quantize(Image)
Quantize an image and return the resulting output bitmap.
Declaration
public Bitmap Quantize(Image source)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | source | The image to quantize. |
Returns
| Type | Description |
|---|---|
| Bitmap | A quantized version of the image. |
QuantizePixel(Quantizer.Color32)
Override this to process the pixel in the second pass of the algorithm.
Declaration
protected abstract byte QuantizePixel(Quantizer.Color32 pixel)
Parameters
| Type | Name | Description |
|---|---|---|
| Quantizer.Color32 | pixel | The pixel to quantize. |
Returns
| Type | Description |
|---|---|
| System.Byte | The quantized value. |
SecondPass(BitmapData, Bitmap, Int32, Int32, Rectangle)
Execute a second pass through the bitmap.
Declaration
protected virtual void SecondPass(BitmapData sourceData, Bitmap output, int width, int height, Rectangle bounds)
Parameters
| Type | Name | Description |
|---|---|---|
| BitmapData | sourceData | The source bitmap, locked into memory. |
| Bitmap | output | The output bitmap. |
| System.Int32 | width | The width in pixels of the image. |
| System.Int32 | height | The height in pixels of the image. |
| Rectangle | bounds | The bounding rectangle. |