Cameron McCormack: > > Or (another possibility): do you want to extract base64-encoded image > > data from an SVG document? For example when you have: > > > > <image xlink:href='data:image/png,Abshfdsy39…'/>
jdomuser: > Yes, thats what i wan to do. I will convert it to a BufferedImage(or some > other image class) and save to disk, modify it with some other code, and > then embed the modified image to its old position.. OK. You can use the ParsedURL class to get an InputStream from that data: URI: http://xmlgraphics.apache.org/batik/javadoc/org/apache/batik/util/ParsedURL.html You can then pass that InputStream to the constructor of org.apache.batik.ext.awt.image.codec.png.PNGImageDecoder, then call decodeAsRenderedImage(0) on it PNGImageDecoder. That will return you a RenderedImage: http://java.sun.com/j2se/1.5.0/docs/api/java/awt/image/RenderedImage.html Then you can convert the RenderedImage to a BufferedImage, using code like shown here: http://www.jguru.com/faq/view.jsp?EID=114602 Once you’ve made the changes to your image, use the PNGImageEncoder class, which will write the PNG data to an OutputStream. For that OutputStream, supply an instance of Base64EncoderStream that is wrapped by a StringWriter. Then set the @xlink:href attribute of the <image> element to be "data:image/png;base64," + yourStringWriter. Hope that helps, Cameron -- Cameron McCormack ≝ http://mcc.id.au/ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
