.net 为什么GifBitmapDecoder播放不完整的gif

.net 为什么GifBitmapDecoder播放不完整的gif,.net,wpf,gif,.net,Wpf,Gif,我想使用GifBitmapDecoder和Int32Animation播放gif图像,但我发现一些gif在播放时不完整 这是我的gif: 这是我的测试代码: GifBitmapDecoder _gifDecoder = new GifBitmapDecoder( new Uri("pack://application:,,,/Expression/f006.gif"), BitmapCreateOptions.PreservePixelForm

我想使用GifBitmapDecoder和Int32Animation播放gif图像,但我发现一些gif在播放时不完整

这是我的gif:

这是我的测试代码:

GifBitmapDecoder _gifDecoder = new GifBitmapDecoder(
            new Uri("pack://application:,,,/Expression/f006.gif"), 
            BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);

foreach (BitmapFrame bf in _gifDecoder.Frames)
{
     Image i = new Image { Source = bf };
     wp.Children.Add(i);
}
Xaml:


结果是:


你能告诉我怎么回事吗,因为我已经搜索了两天,什么也没找到……

单个GIF帧可能只是任意X,Y坐标下图像的一部分

要在图像中正确放置帧,需要帧的X、Y坐标。 阅读这篇关于如何获取此信息的帖子:

然后,要获得完整图像,必须将该帧与前一帧合并,直到获得完整图像。然而,假设你真正的“GIF播放器”只是把动画帧一个接一个地画出来(而不是把它们并排放在StackPanel中),这会自动发生

<WrapPanel Name="wp" ItemHeight="40" ItemWidth="40"/>