Wednesday, October 24, 2007

How to prevent gifs from rendering grainy using .Net GDI

I recently built a Http Handler for an Asp.net application that needed to generate image thumbnails from different image types on the fly. Sounds easy enough, right?

Well it was a simple task until I tried to generate a thumbnail from a gif. After hours and hours trying to figure out how to improve the resolution I found a great article addressing this particular issue.

The key to this conundrum you ask? Color quantization.

Unfortunately System.Drawing uses a web-safe palette even though just about every gif you've ever seen uses an adaptive palette.

The result:

After implementing Brendan Tompkins Octree-based quantization technique...

Wednesday, October 17, 2007

Greenbluff 2007