Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
1.7
-
jdk 1.6
Description
code:
public static void svgToPng(String svgPath, String pngFile) throws Exception {
File svg = new File(svgPath);
FileInputStream wmfStream = new FileInputStream(svg);
ByteArrayOutputStream imageOut = new ByteArrayOutputStream();
int noOfByteRead = 0;
while ((noOfByteRead = wmfStream.read()) != -1)
imageOut.flush();
imageOut.close();
wmfStream.close();
ByteArrayOutputStream jpg = new ByteArrayOutputStream();
FileOutputStream jpgOut = new FileOutputStream(pngFile);
byte[] bytes = imageOut.toByteArray();
PNGTranscoder t = new PNGTranscoder();
TranscodingHints hints = new TranscodingHints();
///hints.put(WMFTranscoder.KEY_INPUT_HEIGHT, 1000);
//hints.put(WMFTranscoder.KEY_INPUT_WIDTH, 8000);
//hints.put(WMFTranscoder.KEY_WIDTH, 800);
// hints.put(WMFTranscoder.KEY_HEIGHT, 600);
//t.setTranscodingHints(hints);
TranscoderInput in = new TranscoderInput(new ByteArrayInputStream(bytes));
TranscoderOutput out = new TranscoderOutput(jpg);
t.transcode(in, out);
jpgOut.write(jpg.toByteArray());
jpgOut.flush();
jpgOut.close();
imageOut = null;
jpgOut = null;
}
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.awt.image.DataBufferInt.<init>(DataBufferInt.java:41)
at java.awt.image.SinglePixelPackedSampleModel.createDataBuffer(SinglePixelPackedSampleModel.java:220)
at java.awt.image.Raster.createWritableRaster(Raster.java:938)
at org.apache.batik.gvt.renderer.StaticRenderer.updateWorkingBuffers(Unknown Source)
at org.apache.batik.gvt.renderer.StaticRenderer.repaint(Unknown Source)
at org.apache.batik.gvt.renderer.StaticRenderer.repaint(Unknown Source)
at org.apache.batik.transcoder.image.ImageTranscoder.transcode(Unknown Source)
at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(Unknown Source)
at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(Unknown Source)
at cn.qtone.xxt.tools.Wmf2Png.svgToPng(Wmf2Png.java:149)
at cn.qtone.xxt.tools.Wmf2Png.convert(Wmf2Png.java:56)
at cn.qtone.xxt.tools.Wmf2Png.main(Wmf2Png.java:34)