GTK# 和 PixbufAnimation 迭代
您好,
我在使用 PixbufAnimation 的 Gdk.PixbufAnimationIter 时遇到问题。代码是这样的:
Gdk.PixbufAnimation animation = new Gdk.PixbufAnimation(System.IO.Path.Combine([filepath], [filename]));
Gdk.PixbufAnimationIter iter = animation.GetIter([Current Time as IntPtr]);
这是我读到的有关 PixbufAnimation.Iter 的内容:
start_time
是指定的开始时间 作为 Python 输出的浮点数time.time()
函数。start_time
标记 动画的开头 播放。
GTK# 没有 time.time() 函数,我尝试了以下方法:
long StartTime = DateTime.Now.Millisecond;
IntPtr SysTime = new IntPtr (&StartTime);
Gdk.PixbufAnimationIter iter = animation.GetIter(SysTime);
但这似乎并不能一致地检索任何时间。由此生成的数字看起来非常随机,并且可能是从内存中的错误地址提取的(只是猜测,不要引用我的话)。
我还从 PixbufAnimation 的另一个文档中读到了这一点:
作为快捷方式,如果 start_time 为
NULL
,g_get_current_time() 的结果
将自动使用。
但是,编译器拒绝允许 IntPtr 使用 NULL
值。
我还读到,“当前时间”仅在您试图扰乱动画时使用,例如使动画显示更快或更慢。
有人可以帮助我吗?
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 Pythontime.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 ofg_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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果将 IntPtr.Zero 传递给 GetIter 方法,则应该与将 NULL 传递给 C 方法相同。老实说,这个 API 在绑定方面有点欠缺,因为 start_time 参数应该是一个 GTimeVal,但在 glib-sharp 中尚未绑定。您当然可以为此提交错误,我们可以扩展 API。例如,我们可以使用 GetIter() 重载来更干净地处理这种情况。
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.