Uploaded image for project: 'Batik'
  1. Batik
  2. BATIK-1064

a bug that is using PNGTranscoder transfer the svg to png.

Agile BoardAttach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    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.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)

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            keyingbo keyingbo
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 1m
              1m
              Remaining:
              Remaining Estimate - 1m
              1m
              Logged:
              Time Spent - Not Specified
              Not Specified

              Slack

                Issue deployment