如何用 Java 创建 gif 动画?
我想从 BufferedImages 集中创建一个 gif 图像。我该怎么做?纯Java中有这样的库吗(ImageMagick不是一个选项)?我找到了 Gif4J 库,但它不是免版税的。
I would like to create a gif image from the set of BufferedImages. How can I do this? Is there such library in pure Java (ImageMagick is not an option)? I've found Gif4J library but it's not royality-free.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我只是在此处回答了类似的问题,但我认为我的解决方案可以提供帮助。
'ImageIcon' 类允许您加载 gif 动画。我使用“getResource()”加载图像。为此,我通常使用 URL 类来传递文件路径。正如名称 URL 所暗示的那样,该路径在远程计算机中不需要是必需的。
path 将是类文件夹内 gif 的路径。
参考:
http://docs.oracle.com/javase/tutorial/ uiswing/components/icon.html#getresource
I just answer a similar question here, but I think that my solution can help.
'ImageIcon' class allows you to load gif animations. I load the image with 'getResource()'. For doing this I normally us URL class to pass the file path. The path does not need to be necessary in a remote machine as the name URL may suggest.
path will be the path of the gif inside of the class folder.
References:
http://docs.oracle.com/javase/tutorial/uiswing/components/icon.html#getresource
有一个图像处理库,类似于 Picasso,它使用 Lifelogger 提到的完全相同的 AnimatedGifEncoder 类 -
Glide 文档,滑翔
There is an image processing library, akin to Picasso which uses the very same AnimatedGifEncoder class mentioned by Lifelogger-
Glide Docs, Glide