xmlgraphics-batik-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Bowditch (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (BATIK-1064) a bug that is using PNGTranscoder transfer the svg to png.
Date Thu, 02 Jan 2014 11:40:51 GMT

    [ https://issues.apache.org/jira/browse/BATIK-1064?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13860145#comment-13860145
] 

Chris Bowditch commented on BATIK-1064:
---------------------------------------

Ok thanks for the reply. Indeed making the image too big could cause the problem. Can you
close the bug please?

> 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: 1.7
>
>         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.1.5#6160)

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-dev-help@xmlgraphics.apache.org


Mime
View raw message