Frage

Greetings,

I'm having a problem using Gdk.PixbufAnimationIter of a PixbufAnimation. The code goes something like this:

Gdk.PixbufAnimation animation = new Gdk.PixbufAnimation(System.IO.Path.Combine([filepath], [filename]));
Gdk.PixbufAnimationIter iter = animation.GetIter([Current Time as IntPtr]);

Here's what I read about PixbufAnimation.Iter:

start_time is the start time specified as a float as output from the Python time.time() function. start_time marks the beginning of the animation playback.

GTK# does not have the time.time() function, and I have tried the following:

long StartTime = DateTime.Now.Millisecond;
IntPtr SysTime = new IntPtr (&StartTime);
Gdk.PixbufAnimationIter iter = animation.GetIter(SysTime);

But that does not seem to retrieve any time consistently. The numbers generated from this seem very random, and are probably pulling from the wrong address in memory (only a guess, don't quote me on that).

I have also read this from another documentation of PixbufAnimation:

As a shortcut, if start_time is NULL, the result of g_get_current_time() will be used automatically.

However, the compiler refuses to allow a NULL value for the IntPtr.

I have also read that the "Current Time" is only used if you are trying to mess with the animation, such as making the animation display faster or slower.

Can anyone out there help me?

War es hilfreich?

Lösung

If you pass IntPtr.Zero to the GetIter method, that should be the same as passing NULL to the C method. This API is a little lacking in the binding, to be honest, as the start_time parameter is supposed to be a GTimeVal which is unbound in glib-sharp as yet. You could certainly file a bug for this and we can extend the API. We could probably use a GetIter() overload, for example, to handle this scenario more cleanly.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top