Re: How to render embedded png?

jonathan wood <[email protected]>
Newsgroups gmane.text.xml.batik.user
Message-ID <CAKiJDQQ8QGheMUWu+nX5qAZT9cKJzrvg-nJD2L7E==yPqRN8nw@mail.gmail.com>
I've had success using the following:

http://xmlgraphics.apache.org/batik/javadoc/org/apache/batik/util/Base64EncoderStream.html

snippet that I use:

...
element.setAttributeNS(SVGConstants.XLINK_NAMESPACE_URI,
SVGConstants.XLINK_HREF_QNAME,
                                                "data:;base64," +
base64Encode(myimagebytearray);

...

    private String base64Encode(final byte[] data) {
        ByteArrayOutputStream b64out = new ByteArrayOutputStream();
        Base64EncoderStream enc = new Base64EncoderStream(b64out);
        try {
            enc.write(data);
        } catch (IOException ex) {
            logger.error(null, ex);
        } finally {
            if (null != enc) {
                try {
                    enc.close();
                } catch (IOException ex) {
                    logger.error(null, ex);
                }
            }
        }
        return b64out.toString();
    }


Hope this helps


On Fri, Sep 7, 2012 at 4:39 AM, ali can <[email protected]> wrote:

> I have an SVG file with an embed image(data:image protocol, png format). I
> am
> not able to find how to render this SVG file correctly. Is there a simple
> example/tutorial on how to render embed images using batik?
>
>
>
> --
> View this message in context:
> http://batik.2283329.n4.nabble.com/How-to-render-embedded-png-tp4655236.html
> Sent from the Batik - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
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.