public OptimizedPaletteQuantizer ConfigureBitLevel(
int? bitLevel
)
Public Function ConfigureBitLevel (
bitLevel As Integer?
) As OptimizedPaletteQuantizer
public:
OptimizedPaletteQuantizer^ ConfigureBitLevel(
Nullable<int> bitLevel
)
member ConfigureBitLevel :
bitLevel : Nullable<int> -> OptimizedPaletteQuantizer
As a primary effect, bitLevel determines the upper limit of the possible colors in the generated palette. For example, if bitLevel is 1, then the result palette will not have more than 8 colors, or when it is 2, more than 64 colors. If you want to quantize an image using the allowed maximum of 65536 colors, then bitLevel should be at least 6 because 5 allows up to 32768 colors.
When using the MedianCut algorithm, configuring the bit level has no other effects. When using the Octree or Wu's algorithms, bitLevel determines also the amount of minimum distinguishable monochromatic shades. For example, when bitLevel is 5, then up to 32 monochromatic shades can be differentiated so close shades might be merged even if the requested number of colors would allow returning all the shades.
For the Octree algorithm the default value is the ceiling of the base 2 logarithm of the requested number of colors (e.g. 1 for 2 colors, 8 for 129 or more colors). This is alright for most cases. You can increase the default value if the image has only a few but very close colors or decrease it if the image has so many colors that the quantization would use too much memory.
For Wu's algorithm the default value is 5 for no more than 256 colors (requires about 1.5 MB fix memory) and 6 for more colors (requires about 10 MB). This provides good enough quality in most cases but may cause visible banding if the input image is monochrome. To avoid that you can increase the bit level, which dramatically increases also the memory requirement: 7 bits requires about 80 MB memory, whereas 8 bits demands about 650 MB, regardless of the actual number of colors in the source image.
ArgumentOutOfRangeException | bitLevel must be either , or between 1 and 8. |