[jira] [Resolved] (BATIK-1064) a bug that is using PNGTranscoder transfer the svg to png.

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Resolved] (BATIK-1064) a bug that is using PNGTranscoder transfer the svg to png.

JIRA jira@apache.org

     [ https://issues.apache.org/jira/browse/BATIK-1064?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

simon steiner resolved BATIK-1064.
----------------------------------
    Resolution: Fixed

> a bug that is using PNGTranscoder transfer the svg to png.
> ----------------------------------------------------------
>
>                 Key: BATIK-1064
>                 URL: https://issues.apache.org/jira/browse/BATIK-1064
>             Project: Batik
>          Issue Type: Bug
>          Components: SVG Rasterizer
>    Affects Versions: 1.7
>         Environment: jdk 1.6
>            Reporter: keyingbo
>              Labels: OutOfMemoryError, PNGTranscoder
>             Fix For: trunk
>
>         Attachments: 7cd55.svg
>
>   Original Estimate: 1m
>  Remaining Estimate: 1m
>
> 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.write(noOfByteRead);
> }
> 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)



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]