xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lars Eirik Rønning" <larsei...@gmail.com>
Subject Re: Manipulation of existing svg document
Date Wed, 28 May 2008 08:13:22 GMT
Thanks for helping.
I actually wish to only open the file and get its base64encoding. Note that
in my case i do not have  bufferedImage, i merely wish to open the fileURI
and have the bytes encoded to base64.
I have found a base64Enocder class which may be used (org.apache.codec)

As i understand it the Base64EncoderStream class in Batik requires an
renderedImage as input, but this is not what i am looking at.
If i also understand you correct, the transform element is not required in
order for an image to appear, only if i wish to do some transformation to
the image, such as translating it or skewing and so forth.

On Wed, May 28, 2008 at 10:07 AM, Cameron McCormack <cam@mcc.id.au> wrote:

> Hi Lars.
> Lars Eirik Rønning:
> > I have an existing svg document where some of the nodes act as
> placeholders.
> > Basically these placeholders will be replaces with base64 encoded images.
> >
> > 1:Are there any convenience methods for adding images to an svg document
> or
> > do i have to manually base64encode the stream and add all attributes such
> as
> > widht and height?
> > I have already added an element using the SVGConstant for Images, but to
> mee
> > this still looks like its more or less the same as using any other
> > xmldocument.
> If you have, say, a BufferedImage and you want to convert it into a
> data: URI, you can do the following:
>  BufferedImage img = …;
>  ByteArrayOutputStream bytes = new ByteArrayOutputStream();
>  Base64EncoderStream b64 = new Base64EncoderStream(bytes);
>  PNGImageEncoder enc = new PNGImageEncoder(b64, null);
>  enc.encode(img);
>  b64.close();
>  String uri = "data:image/png;base64," + bytes.toString();
> Then you can construct a new <image> element and set its xlink:href=""
> attribute to that URI.  This is essentially what the SVGGraphics2D class
> does when it gets a drawImage() call.
> > If there are any guides or tutorials to using dom for handling images i
> am
> > very happy to receive some pointers..
> > 2:One of my concerns is that i probably have to add the transformation
> > matrix myself. I was hoping that there could be some convenience methods
> > which would help me on my way for doing these types of operations.
> > Is the transformation matrix necessary in order for the image (or any
> > element) to be visible in a svg document?
> I'm not quite sure what you want to achieve, so I don't know whether you
> need to set a transform='" on the <image> elements or not.
> --
> Cameron McCormack ≝ http://mcc.id.au/
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
View raw message