I am currently using SVGGraphics2D to create a SVG file. I was able to have a SVG file as an output by drawing shapes on it but then what I need is to have a bufferedimage - a PNG file, drawn in the SVG document. The following are the current codes I am working with.
Question: What should be the proper process to draw a bufferedimage in a SVG document?
Method to draw the image from source.
public void paintImage(Graphics g) throws IOException {
File imageSrc = new File("C:\\Users\\anthony\\Downloads\\SVGGraphics2D\\src\\svggraphics\\eg.png");
BufferedImage img = ImageIO.read(imageSrc);
Graphics2D g2d = (Graphics2D) img.getGraphics();
g2d.drawImage(img,0,0,null);
}
Creates SVG document.
public static void main(String [] args) throws IOException {
DOMImplementation domImpl = GenericDOMImplementation.getDOMImplementation();
String svgNS = "http://www.w3.org/2000/svg";
Document document = domImpl.createDocument(svgNS, "svg", null);
SVGGraphics2D graphics = new SVGGraphics2D(document);
TestSVGGenerator test = new TestSVGGenerator();
test.paintImage(graphics);
boolean useCSS = true;
Writer out = new OutputStreamWriter(new FileOutputStream("test.svg"), "UTF-8");
graphics.stream(out, useCSS);
}