views:

620

answers:

1

I'm trying to extract thumnail images of each frame in an animated gif. The following code is how I'm tyring to do it, but the thumbnail property of the BitmapFrame instance is always null.

Am I doing something wrong?


GifBitmapDecoder bd1 = new GifBitmapDecoder(
new Uri(thisImage.Path), BitmapCreateOptions.None, BitmapCacheOption.Default);
if (bd1.CheckAccess())
{
    if (bd1.Frames.Count > 1)
    {
     foreach (var frame in bd1.Frames)
     {
      BitmapSource frameThmb = frame.Thumbnail;
      if (frameThmb != null)
       Console.WriteLine(frameThmb.Width);
     }
    }
}
+1  A: 

There is no thumbnail available for GIFs.

From MSDN Libary: "None of the native formats support global thumbnails. Joint Photographics Experts Group (JPEG), Tagged Image File Format (TIFF), and Microsoft Windows Media Photo support frame-level thumbnails that can be accessed using the Thumbnail property. " (http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.bitmapdecoder.thumbnail.aspx)

Either use TIFF (as you mention in the question title) or you'll have to generate the thumbnails yourself (which shouldn't be too hard?)

Oskar