I want to display some images on a canvas accordingly to screen dimension without losing the image resolution.
If I use a simple png or jpeg, I will see the image pixelized on a big screen.
What I am thinking is to use svg files and display them on the janvas. Is something like that possible? (I tried to use Apache Batik without a possitive result)
if this is not possible, can you think any other alternative?
Apache Commons has Batik Swing component
containing special canvas JSVGCanvas
. This is the best approach you can find.
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
Any problem you can share with us? Here and here you will find how to implement it.
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");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With