我想在不损失图像分辨率的情况下根据屏幕尺寸在 Canvas 上显示一些图像。
如果我使用简单的 png 或 jpeg,我会在大屏幕上看到像素化的图像。
我想的是用svg文件,在janvas上显示出来。这样的事情可能吗? (我尝试使用 Apache Batik 没有得到肯定的结果)
如果这是不可能的,你能想到其他替代方案吗?
最佳答案
Apache Commons 有 Batik Swing component
含特殊 Canvas JSVGCanvas
.这是您能找到的最佳方法。
The goal of the
Batik Swing
component module is to provide aSwing
component that can used to displaySVG
documents. With theJSVGCanvas
class, you can easily display an SVG document (from a URI or a DOM tree) and allow the user to manipulate it, such as rotating, zooming, panning, selecting text or activating hyperlinks.
I tried to use Apache Batik without a possitive result
您有什么问题可以与我们分享吗? Here和 here您将了解如何实现它。
public SVGCanvasDemo(JFrame frame) {
frame.getContentPane().setLayout(new BorderLayout());
frame.getContentPane().add("Center", svgCanvas);
frame.setVisible(true);
svgCanvas.setURI("file:/c:/files/hungryminds/rectangles.svg");
}
关于java - 在 Canvas 上显示 svg,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33870276/