问题描述
是否有办法找出单循环动画GIF需要多长时间?
Is there a way to find out how long a single-loop animated GIF will take to finish?
推荐答案
好吧,具体的排序方式取决于您用来操纵这些动画GIF的接口(我不知道原生Java/AWT/Swing),但是基本思想是计算(帧速率*帧数).
Well, the specifics sorta depends on what interface you're using to manipulate those animated GIFs (I'm not aware of a real slick way in native Java/AWT/Swing), however the basic idea would to calculate (frame rate * number of frames).
如果您要手动编写GIF操纵工具,建议您查看 http://www.onicos.com/staff/iz/formats/gif.html
If you're coding a GIF manipulation tool by hand, I recommend taking a look at http://www.onicos.com/staff/iz/formats/gif.html
希望这至少会有所帮助.
Hope this helps at least a little.
更新:尝试实现ImageObserver接口.查看该类中的ImageObserver.FRAMEBITS标志,以检测帧更新. http://docs.oracle.com/javase/6/docs/api/java/awt/image/ImageObserver.html
Update: Try implement the ImageObserver interface. Take a look at the ImageObserver.FRAMEBITS flag in that class to detect frame updates. http://docs.oracle.com/javase/6/docs/api/java/awt/image/ImageObserver.html
这仍然留下了gif有多少帧的问题.您可能想尝试看看Image.getProperty()函数.我在查找有关是否有框架"属性的文档时遇到了一些困难,但请看一下.
This still leaves the question of how many frames the gif has. You might want to try taking a look at the Image.getProperty() function. I'm having some difficulty finding documentation as to whether there's a "frame" property, but take a look.
这篇关于如何从动画GIF中获取长度(及时)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!