(WPF) How to extract frames from multiframe images (tif, gif)

只谈情不闲聊 提交于 2019-12-24 07:59:49

问题


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:


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"

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



来源:https://stackoverflow.com/questions/951786/wpf-how-to-extract-frames-from-multiframe-images-tif-gif

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!