(WPF)如何从多帧图像中提取帧(tif,gif) [英] (WPF) How to extract frames from multiframe images (tif, gif)

查看:310
本文介绍了(WPF)如何从多帧图像中提取帧(tif,gif)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试提取动画gif中每一帧的缩略图图像.以下代码是我的尝试方式,但是BitmapFrame实例的thumbnail属性始终为null.

我做错什么了吗?


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);
        }
    }
}

解决方案

GIF没有缩略图.

从MSDN Libary: 所有本机格式都不支持全局缩略图.联合图像专家组(JPEG),标记图像文件格式(TIFF)和Microsoft Windows Media Photo不支持可以使用

要么使用TIFF(如您在问题标题中所述),要么您必须自己生成缩略图(这应该不太难吗?)

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);
        }
    }
}

解决方案

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

这篇关于(WPF)如何从多帧图像中提取帧(tif,gif)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆