Sunday, December 29, 2013

Update on the GIF creator (sharpGIFs 2.0)

Okay, so the last bit of code i wrote had the flaw of not letting the gif's loop.
It seems that for a gif to automatically loop you need to set some custom metadata for the file containing "NETSCAPE 2.0" for some reason. This probably dates back to looping gif's being first introduced in that very browser (GIF89a support).


The most intuitive fix for my program would be to just add this metadata to the GifBitmapEncoder before saving the file. However, for some reason this throws an exception "The designated BitmapEncoder does not support global metadata." Ironically it seems the GifBitmapEncoder is the only BitmapEncoder that doesn't support metadata.

So i was unable to actually fix my program. But luckily i found some code that works, using a different aproach to the problem (using MemoryStream and BinaryWriter).
The original code bit was found here, i haven't really done much in terms of changing anything. Just removing a reference to Response out and changing the delay time to something reasonable. Then i threw in the resizing bit from the last project.

So anyways, here are the code zipped as usual.
sharpGIFs 2.0.zip

And here are the final gif (same images as the post below, just looping this time around):


No comments:

Post a Comment