Luigi Rosso
.NET Image Tools GIF Bug Fix

One of the projects we’re working on over at http://archetype-inc.com/ needed to display GIF images on Microsoft’s new WP7. There’s no native support for GIFs in Silverlight 3 (or 4) but there is a pretty comprehensive library that adds GIF support along with a bunch of other features. It’s the .NET Image Tools library and it’s available here:
http://imagetools.codeplex.com/

I ran into an odd issue where some GIFs weren’t decoding. I looked around a bit and it seems like this is a known issue:
http://imagetools.codeplex.com/workitem/5483

Someone was nice enough to diagnose the issue and figure out that it had to do with interlaced GIFs, sure enough the GIFs giving me trouble were interlaced ones. I peaked into the code and found a great little article that described how the interlacing is supposed to work here:
http://www.prepressure.com/library/file-formats/gif

It was a pretty simple fix, however I’m not 100% certain about whether or not this works when the image descriptor starts the image at any offset other than 0 (vertically). I made some assumptions there, feel free to correct them if they’re wrong (please do let me know) or if you run into other issues!

If you’re seeing this issue, just replace your ImageTools\ImageTools.IO.Gif\GifDecoder.cs with the one in the archive attached here and recompile the library.

http://archetype-inc.com/BlogAssets/ImageToolsFix/GifDecoder.zip

  1. luigi-rosso posted this
blog comments powered by Disqus