Best quality dithering library in C
-
13-04-2021 - |
Question
I'm developing a texture atlas packer to use with OpenGL, and I'm currently looking for an open-source (it's better if it's a library, but an open-source software would be good as well!) solution that will render the best results for color palette creation / dithering. It really doesn't need to be fast, but needs to achieve optimal results. It would be best if there is a possibility for 4-bit-per-pixel palette generation.
La solution
pngquant is available as a pure C library.
ImageMagick uses octtree, which is fast, but not the best quality.
pngquant uses MedianCut with several additional improvements, and is likely to give higher quality.
pngquant has speed/quality trade-off setting which can improve quality a bit further, and also has custom dithering algorithm (variation of Floyd-Steinberg) that doesn't add noise to well-quantized areas of the image.
Autres conseils
Imagemagick is a very powerful C library for graphical manipulation: http://www.imagemagick.org/ It has commandline tools, but can also be used as a C library.
For future reference, I found PNGNQ, which is a pretty good library for image quantization. Their samples are amazing.