[Gtk-sharp-list] Getting frames from a GIF animation
Doug Blank
doug.blank at gmail.com
Thu Apr 11 01:58:24 UTC 2013
I couldn't figure out how to access the data through Gtk#, so I got
the data through System.Drawing:
public static List loadPictures (string filename)
{
List list = new List();
System.Drawing.Bitmap image =
(System.Drawing.Bitmap)System.Drawing.Bitmap.FromFile(filename);
System.Drawing.Imaging.FrameDimension dimension = new
System.Drawing.Imaging.FrameDimension(image.FrameDimensionsList[0]);
int frame_count = image.GetFrameCount(dimension);
for (int i=0; i < frame_count; i++) {
image.SelectActiveFrame(dimension, i);
list.append( new Graphics.Picture(image));
}
return list;
}
-Doug
On Wed, Apr 10, 2013 at 1:41 PM, Doug Blank <doug.blank at gmail.com> wrote:
> Gtk-sharp List,
>
> I can use the Gtk# interface to get the frames of a gif animation
> based on time, like the following IronPython code shows:
>
> image = Gtk.Image(filename)
> if image.Animation:
> if not image.Animation.IsStaticImage:
> iter = image.Animation.GetIter(System.IntPtr.Zero)
> while iter.DelayTime > -1:
> pixbuf = iter.Pixbuf
> ## do something with pixbuf
> iter.Advance(System.IntPtr.Zero) ## advance to current time
>
> But, can I actually get the actual individual *frames* from the gif
> file? That is, I can use this interface to step through time getting
> the appropriate image for the specified time, but if an animated gif
> has 7 gifs in it, is there a direct way to just get the 7 pixbufs?
>
> Thanks for any pointers,
>
> -Doug
More information about the Gtk-sharp-list
mailing list