Thomas, thanks, this is a great simple approach. I will give it a try.

Just for the record, the approach solution indicated in the initial question does work also, but of course it is not as simple.

Andres.

On Feb 14, 2005, at 10:59 AM, Thomas DeWeese wrote:

Andres Toussaint wrote:

My Main question is: How is the best way to add this image into my document?

Encode it as a PNG and include it in the xlink:href using the data protocol. This is what the code below does (very indirectly).

    The code to do this more directly (take from
batik.svggen.ImageHandlerBase64Encoder) is something like:

    public static final String DATA_PROTOCOL_PNG_PREFIX =
        "data:image/png;base64,";;

        ByteArrayOutputStream os = new ByteArrayOutputStream();
        Base64EncoderStream b64Encoder = new Base64EncoderStream(os);

        ImageEncoder encoder = new PNGImageEncoder(b64Encoder, null);
        encoder.encode(buf);

        // Close the b64 encoder stream (terminates b64 streams).
        b64Encoder.close();

        imageElement.setAttributeNS(XLINK_NAMESPACE_URI,
                                    ATTR_XLINK_HREF,
                                    DATA_PROTOCOL_PNG_PREFIX +
                                    os.toString());

Also, will doing this approach create a Embedded Image in my SVG? Or how is the reference to the Image handled? What format of image will be embedded (PNG, JPG,...)?

The above will embed the image in the SVG.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to