xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kayser <kotu...@yahoo.com>
Subject Convert into PNG on the fly
Date Thu, 17 Nov 2011 11:06:40 GMT
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.

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


Mime
View raw message