在 GTK# Image Widget 中显示动画 GIF

Show Animated GIF in GTK# Image Widget

我想在 GTK# 图像小部件中显示动画 GIF 以表示长时间的 运行 后台操作。我尝试打开 GIF 并设置 Pixbuf,但没有出现动画。有什么办法可以做到这一点?

是的。您需要设置 PixbufAnimation property of the Gtk.Image to a Gdk.PixbufAnimation rather than setting the Pixbuf property.

例如:

// http://www.gifbin.com/987026
string gifPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "../../1351183938_high_school_football_player_kicks_67yard_goal.gif");
image1.PixbufAnimation = new Gdk.PixbufAnimation(gifPath);

我在装有 libgtk2.0-cil-dev 2.12.10-5 的 Ubuntu 14.04.2 LTS 'Trusty Tahr' 机器上测试了上面的内容,并看到了动画播放。