DynamicPDF Rasterizer supports dithering. Dithering is a computer graphics technique that reduces the visual side effects of color quantization. A quantized image may contain flat areas and patches of color that may significantly affect the quality of the quantized image. Dithering creates an illusion of more color and more detail by mixing available colors. Factors such as original image quality, dithering algorithm used, dithering percentage, and color palette can all affect the resulting dithered image's quality.
Guidelines for selecting Dithering Algorithms
DynamicPDF Rasterizer supports the Floyd-Steinberg algorithm and Bayer dithering algorithms.
The Floyd-Steinberg algorithm is a high-quality error-diffusion method. It is the default dithering algorithm DynamicPDF Rasterizer uses during indexed image creation. This method can be used for creating both monochrome images and color images. The Floyd-Steinberg algorithm higher quality images compared to the Bayer algorithm, but the trade-off is that creating images using the Floyd-Steinberg algorithm is slower than when using the Bayer algorithm.
The Bayer algorithm is an ordered dithering algorithm. The Bayer algorithm can be used for creating both monochrome images and color images. Although image quality is lower when using the Bayer algorithm, the algorithm creates images faster than when using the Floyd-Steinberg algorithm.
Guidelines for selecting Dithering Percentage
DynamicPDF Rasterizer supports setting dithering percentage for an image to be set from zero to 100. The dithering percentage specifies the percentage of pixels that will undergo dithering. Zero percent dithering results in no pixels being dithered and the resulting image may contain bands and patches. You avoid this poor image quality by setting the dithering to an appropriate value. For dithering percentages greater than zero, the higher the percentage, the greater the illusion of more color and more detail. However, as the image quality improves, so does the file size. If a small file size is of greater importance than image quality, then select a lower dithering percentage. Images with primarily solid colors (Example: A PDF e-book’s pages converted to image) often work well with a lower dithering percentage. In contrast, images with gradients and containing more colors often require a higher dithering percentage to prevent color banding. Some experimentation with the optimal dithering percentage is often required.
The following example illustrates rasterizing a PDF document into an indexed PNG using the Floyd-Steinberg dithering algorithm at a dithering percentage of 100%.
PdfRasterizer rasterizer = new PdfRasterizer(pdfFilePath); AutoPalette autoPalette = new AutoPalette(QuantizationAlgorithm.Octree, 256); PngIndexedColorFormat pngIndexedColorFormat = new PngIndexedColorFormat(autoPalette, 100, DitheringAlgorithm.FloydSteinberg); PngImageFormat png = new PngImageFormat(pngIndexedColorFormat); rasterizer.Draw(pngFilePath, png, ImageSize.Dpi72);
Dim rasterizer As New PdfRasterizer(pdfFilePath) Dim autoPalette As New AutoPalette(QuantizationAlgorithm.Octree, 256) Dim pngIndexedColorFormat As New PngIndexedColorFormat(autoPalette, 100, DitheringAlgorithm.FloydSteinberg) Dim png As New PngImageFormat(pngIndexedColorFormat) rasterizer.Draw(pngFilePath, png, ImageSize.Dpi72)