ImageResizer
3.4.0
|
Abstract Quantizer class - handles the messy, algorithm-independent details of quantization. Subclasses must implement InitialQuantizePixel, GetPallete(), and QuantizePixel. Not thread-safe! More...
Classes | |
struct | Color32 |
Struct that defines a 32 bpp colour More... | |
Public Member Functions | |
Quantizer (bool fixedPalette) | |
Construct the quantizer More... | |
virtual void | Reset () |
Resets the quantizer so it can process a new image. More... | |
Bitmap | Quantize (Image src) |
Quantize an image and return the resulting output bitmap More... | |
Protected Member Functions | |
virtual void | ValidatePropertyValues () |
Bitmap | QuantizeFullTrust (Bitmap firstPass, Bitmap copy, Bitmap copy2, Bitmap output) |
Bitmap | QuantizeLowTrust (Bitmap firstPass, Bitmap copy, Bitmap copy2, Bitmap output) |
virtual void | AnalyzeImage (BitmapData sourceData, int width, int height) |
Execute the first pass through the pixels in the image More... | |
virtual void | AnalyzeImageLowTrust (Bitmap b, int width, int height) |
virtual void | QuantizeImage (BitmapData sourceData, BitmapData intermediate, Bitmap output, int width, int height, Rectangle bounds) |
Execute a second pass through the bitmap. If dithering is enabled, sourceData will be modified. More... | |
void | AdjustNeighborSource (int offsetX, int offsetY, int deltaR, int deltaG, int deltaB, int deltaA) |
Can only be called from QuantizePixel... This is how dithering is done... 5-18-09 ndj More... | |
byte | ToByte (int i) |
virtual void | InitialQuantizePixel (Color32 pixel) |
Override this to process the pixel in the first pass of the algorithm More... | |
abstract byte | QuantizePixel (Color32 pixel) |
Override this to process the pixel in the second pass of the algorithm More... | |
abstract ColorPalette | GetPalette (ColorPalette original) |
Retrieve the palette for the quantized image More... | |
Properties | |
bool | FixedPalette [get] |
(Readonly) If true, the algorithm can do everything in QuantizePixel, and InitialQuantizePixel will not be called. Implies ResizeForFirstPass=False and FourPass=false= More... | |
int | PixelSize [get] |
The number of bytes in a ARGB structure. Should be 4 More... | |
bool | FullTrust [get, set] |
If true, pointer arithmetic will be used instead of GetPixel. GetPixel is much slower. If false, OmitFinalStage will be assumed true, as only palette generation is possible in low trust. Defaults to true. More... | |
bool | ResizeForFirstPass [get, set] |
If true, the first pass (InitialQuantizePixel) will be performed on a size-limited version of the original image to control performance. Ignored if FixedPalette=True More... | |
long | FirstPassPixelCount [get, set] |
The approximate number of pixels to use when making a scaled copy of the image for the first pass. Only used when ResizeForFirstPass=True and FirstPassPixelThreshold is exceeded. More... | |
long | FirstPassPixelThreshold [get, set] |
The maximum number of pixels the original image may contain before a scaled copy is made for the first pass. Only relevant when ResizeForFirstPass=True More... | |
bool | FourPass [get, set] |
If true, image is re-paletted after quantization - forces 2 clones of the original image to be created. FixedPalette and OmitFinalStage should be false if this is used. More... | |
bool | OmitFinalStage [get, set] |
If true, a 32-bit image with an 8-bit palette will be returned instead of an 8-bit image, which GDI can save using median-cut quantization. Much faster than our final quantization pass, although it can't do transparency. Assumed true if FullTrust is false. More... | |
Abstract Quantizer class - handles the messy, algorithm-independent details of quantization. Subclasses must implement InitialQuantizePixel, GetPallete(), and QuantizePixel. Not thread-safe!
Definition at line 31 of file Quantizer.cs.
|
inline |
Construct the quantizer
fixedPalette | If true, the quantization only needs to loop through the source pixels once - InitialQuantiize |
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'.
Definition at line 122 of file Quantizer.cs.
|
inlineprotected |
Can only be called from QuantizePixel... This is how dithering is done... 5-18-09 ndj
offsetX | |
offsetY | |
deltaR | |
deltaG | |
deltaB | |
deltaA |
Definition at line 461 of file Quantizer.cs.
|
inlineprotectedvirtual |
Execute the first pass through the pixels in the image
sourceData | The source data |
width | The width in pixels of the image |
height | The height in pixels of the image |
Definition at line 323 of file Quantizer.cs.
|
protectedpure virtual |
Retrieve the palette for the quantized image
original | Any old palette, this is overrwritten |
Implemented in ImageResizer.Plugins.PrettyGifs.OctreeQuantizer.
|
inlineprotectedvirtual |
Override this to process the pixel in the first pass of the algorithm
pixel | The pixel to quantize |
This function need only be overridden if your quantize algorithm needs two passes, such as an Octree quantizer.
Reimplemented in ImageResizer.Plugins.PrettyGifs.OctreeQuantizer.
Definition at line 513 of file Quantizer.cs.
|
inline |
Quantize an image and return the resulting output bitmap
source | The image to quantize |
Definition at line 151 of file Quantizer.cs.
|
inlineprotectedvirtual |
Execute a second pass through the bitmap. If dithering is enabled, sourceData will be modified.
sourceData | The source bitmap, locked into memory |
intermediate | The intermediate bitmap, used for 4-pass quantization. If specified, output will not actually be modified |
output | The output bitmap |
width | The width in pixels of the image |
height | The height in pixels of the image |
bounds | The bounding rectangle |
Definition at line 371 of file Quantizer.cs.
|
protectedpure virtual |
Override this to process the pixel in the second pass of the algorithm
pixel | The pixel to quantize |
Implemented in ImageResizer.Plugins.PrettyGifs.OctreeQuantizer.
|
inlinevirtual |
Resets the quantizer so it can process a new image.
Reimplemented in ImageResizer.Plugins.PrettyGifs.OctreeQuantizer.
Definition at line 131 of file Quantizer.cs.
|
getset |
The approximate number of pixels to use when making a scaled copy of the image for the first pass. Only used when ResizeForFirstPass=True and FirstPassPixelThreshold is exceeded.
Definition at line 75 of file Quantizer.cs.
Referenced by ImageResizer.Plugins.PrettyGifs.PrettyGifs.SaveIndexed().
|
getset |
The maximum number of pixels the original image may contain before a scaled copy is made for the first pass. Only relevant when ResizeForFirstPass=True
Definition at line 85 of file Quantizer.cs.
Referenced by ImageResizer.Plugins.PrettyGifs.PrettyGifs.SaveIndexed().
|
get |
(Readonly) If true, the algorithm can do everything in QuantizePixel, and InitialQuantizePixel will not be called. Implies ResizeForFirstPass=False and FourPass=false=
Definition at line 38 of file Quantizer.cs.
|
getset |
If true, image is re-paletted after quantization - forces 2 clones of the original image to be created. FixedPalette and OmitFinalStage should be false if this is used.
Definition at line 96 of file Quantizer.cs.
|
getset |
If true, pointer arithmetic will be used instead of GetPixel. GetPixel is much slower. If false, OmitFinalStage will be assumed true, as only palette generation is possible in low trust. Defaults to true.
Definition at line 56 of file Quantizer.cs.
|
getset |
If true, a 32-bit image with an 8-bit palette will be returned instead of an 8-bit image, which GDI can save using median-cut quantization. Much faster than our final quantization pass, although it can't do transparency. Assumed true if FullTrust is false.
Definition at line 107 of file Quantizer.cs.
|
get |
The number of bytes in a ARGB structure. Should be 4
Definition at line 47 of file Quantizer.cs.
|
getset |
If true, the first pass (InitialQuantizePixel) will be performed on a size-limited version of the original image to control performance. Ignored if FixedPalette=True
Definition at line 66 of file Quantizer.cs.