我正在尝试在动画gif中提取每个帧的thumnail图像。下面的代码是我如何使用它,但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);
}
}
}
答案 0 :(得分:1)
GIF没有可用的缩略图。
来自MSDN Libary: “所有原生格式均不支持全局缩略图。联合图像专家组(JPEG),标记图像文件格式(TIFF)和Microsoft Windows Media Photo支持可使用Thumbnail property"访问的帧级缩略图
要么使用TIFF(正如您在问题标题中提到的那样),要么您必须自己生成缩略图(这不应该太难?)