comentsys.wordpress.com today features a Universal Windows Platform tutorial showing how to create a GifView App which will allow you to Open and Play Animated GIFs – plus you can also Stop the playback of the animation.
Details
The Library Class is quite simple with just one method called Open which contains a FileOpenPicker set to open a “.gif” file and then sets the passed in BitmapImage to be the opened file using PickSingleFileAsync to get the file and SetSourceAsync to set the image from the file with OpenReadAsync.
The MainPage has three AppBarButton controls; Open – to trigger an event, Play which uses the Click event to trigger a bound expression to call Play on the BitmapImage and Stop to trigger a bound expression to call Stop on the BitmapImage. Plus there’s the Display itself which is the BitmapImage.
Behind the Scenes
This example was inspired from the Microsoft Universal Windows Platform (UWP) app samples and in particular the Animated GIF Playback example – the goal was to create a simpler implementation of this and found that the bound expressions made it really simple anyway, so the way the animated GIF is played or stopped is the same and demonnstrated a really great technique to trigger events in another object. Also provided was a sample animated GIF which is an extract from the Big Buck Bunny video from the Blender Foundation.