如何在Java中高性能地显示多个SVG
我想要的
我的目标是能够在 Java 的单个绘图区域上显示大量 SVG 图像,每个图像都有自己的平移/旋转/缩放值。我正在寻找允许此操作的最简单的解决方案,甚至可以选择使用 OpenGL 来加快速度。
我的尝试
我最初的简单方法是使用 SVGSalamander 直接在 JPanel 上绘图,但性能很差。
我四处寻找,了解到我应该做一些事情,比如手动将每个 SVG 转换为使用 createCompatibleImage 创建的 BufferedImage,然后进行我想要的转换,然后使用双缓冲绘制它。我在这里遇到了一些麻烦,在继续之前我尝试寻找框架来简化事情。
我所看到的
我对可用的选项有点不知所措,这就是为什么我向 SO 寻求帮助。我看过:
- 开罗(与Glitz 也许?)
- Libart< /a> - 不确定这是否真的支持 SVG
- FengGUI
- Slick - 看起来很有希望,但有点矫枉过正,
但无法决定什么最适合我开始工作,我希望这里有人有做类似事情的经验。
What I want
My goal is to be able to display a large number of SVG images on a single drawing area in Java, each with its own translation/rotation/scale values. I'm looking for the simplest solution allowing this, optionally even using OpenGL to speed things up.
What I've Tried
My initial naive approach was to use SVGSalamander to draw directly on a JPanel, but the performance was pathetic.
I poked around around and learned that I should do something like manually convert each SVG into a BufferedImage created with createCompatibleImage, then do the transformations I want, then draw it using double buffering. I ran into some troubles here, and before I continued I tried looking for frameworks to simplify things.
What I've Looked At
I've been a bit overwhelmed by the available options, which is why I'm turning to SO for help. I've looked at:
- Cairo (with Glitz maybe?)
- Libart - not sure if this actually supports SVGs
- FengGUI
- Slick - looks promising but a bit of an overkill
But couldn't decide what is best for me to start working with, and I hope someone here as experience with any of these doing similar things.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将 SVG 渲染为纹理,然后使用所需的变换渲染纹理四边形。
Render your SVGs to textures, then render textured quads with desired transforms.