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 <alican1...@hotmail.com> 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: batik-users-unsubscr...@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org
>
>

Reply via email to