Convert into PNG on the fly

Kayser <[email protected]>
Newsgroups gmane.text.xml.batik.user
Message-ID <[email protected]>
I try to convert an svg into PNG. the svg document is coming from a server as
a Inputstream.
First, I convert the svg stream into byte array with:

     byte[] streamBytes = IOUtils.toByteArray(svgStream);

Then i convert the bytes into outputstream(PNG).    

private ByteArrayOutputStream svgToPng(byte[] streamBytes)
                                            throws TranscoderException,
IOException {
        PNGTranscoder t = new PNGTranscoder();
        TranscoderInput input = new TranscoderInput(new
ByteArrayInputStream(streamBytes));
        ByteArrayOutputStream ostream = new ByteArrayOutputStream();
        TranscoderOutput output = new TranscoderOutput(ostream);

        t.transcode(input, output);

        ostream.flush();
        // ostream.close();
        return ostream;
    }

Note: If i save the svgstream on th disk and use the following
transcoderinput with uri constructor, then it works. But in my case i don't
want to save on the disk.

TranscoderInput input = new TranscoderInput(new
File("c:/a.svg").toURI().toString());


--
View this message in context: http://batik.2283329.n4.nabble.com/Convert-into-PNG-on-the-fly-tp4079626p4079626.html
Sent from the Batik - Users mailing list archive at Nabble.com.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.