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):


Thursday, December 26, 2013

Create animated GIF's with C#

I got a brand new camera this christmas, a GoPro Hero3+. The camera shoots amazing Full HD video at action-enabling framerates. And the waterproof casing and small form factor makes this the best damned piece of gear i own.

And after spending hours on hours of tumbling in the snow videoing myself fighting with the dog and jumping off cliffs skiing i started exploring the various other functions the camera has.

One of wich is the ability to take 30 pictures in 3 seconds.
Combined with a handy wifi-remote makes for alot of fun shots.

Then after having 500+ still frames of action recorded on the SD card i realized it would be fun making animated GIF's with them. A quick google search gave me lots of online-sites for just this purpose, but the first one i tried gave me a "picture too large" -error.

And being  the programmer i am, and having a few hours of post-christmas tranquility i immediately decided that i would rather make my own GIF-converter than manually resize my images to fit the online-converter.

Granted, the next few search results would probably solved my problem, but im allways trying to keep my coding skills from decay, and this presented it self as a good opurtunity.

So here is the result of a couple hours of dabbeling i Visual Studio:
The VisualStudio project can be downloaded as a .zip from this link

And a .gif example:


For some reason the gif will not loop, but im working on a fix for that.