问题描述
我的目标是能够在Java的单个绘图区域上显示大量SVG图像,每个图像都有自己的平移/旋转/比例值。我正在寻找允许这个的最简单的解决方案,可选择甚至使用OpenGL来加快速度。
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.
我最初的天真方法是使用SVGSalamander直接在JPanel上绘制,但性能很可怜。
My initial naive approach was to use SVGSalamander to draw directly on a JPanel, but the performance was pathetic.
我四处乱逛并了解到我应该做一些事情,比如手动将每个SVG转换为用createCompatibleImage创建的BufferedImage,然后进行我想要的转换,然后使用双缓冲绘制它。我在这里遇到了一些麻烦,在我继续之前,我试图寻找框架来简化事情。
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.
我对可用的选项感到有点不知所措,这就是为什么我转向SO寻求帮助的原因。我看过:
I've been a bit overwhelmed by the available options, which is why I'm turning to SO for help. I've looked at:
- (可能吗?)
- - 不确定这是否真的支持SVG
- - 看起来很有希望,但有点矫枉过正
- 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.
推荐答案
将SVG渲染为纹理,然后使用所需的变换渲染纹理四边形。
Render your SVGs to textures, then render textured quads with desired transforms.
这篇关于如何在Java中以高性能显示许多SVG的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!