Warren, The org.apache.batik.transcoder.image.ImageTranscoder class should be exactly what you want. If you are trying to convert images to PNG or JPEG, you may even be able to use the PNGTranscoder or the JPEGTranscoder directly. If you are trying to do something else, implementing your own ImageTranscoder and using PNGTranscode and JPEGTranscoder as sources of inspiration.
May be Thierry, who wrote the transcoder framework, will have more comments. Cheers, Vincent. "Warren W. Thompson" wrote: > > I am attempting to render an SVG image file as a java.awt.Image, or one > of its subclasses like java.awt.image.BufferedImage. I have attempted to > directly render the SVG file and I have also attempted to transcode it. > I am currently using Batik version 1.1. > > I have achieved the most success with the following code snippet; however, > the BufferedImage that is returned is the correct shape without any colors > or details being drawn. I feel that I am missing some step in the rendering > process, and I have looked in detail at the Batik documentation and mailing > list archives to no avail. > > public static Image renderSVGDocument( URL url, int x, int y ){ > // Create a rendereing context. > UserAgent userAgent = new UserAgentAdapter(); > DocumentLoader loader = new DocumentLoader( userAgent ); > Document doc = null; > try { > doc = loader.loadDocument( url.toString() ); > } catch( Exception ex ){ > ex.printStackTrace(); > } > BridgeContext ctx = new BridgeContext(userAgent, loader); > > // Create a buffered image. > BufferedImage bufImg = > new BufferedImage( x, y, BufferedImage.TYPE_INT_ARGB ); > Graphics2D graphics = GraphicsUtil.createGraphics( bufImg ); > > // Create a builder and root node. > GVTBuilder builder = new GVTBuilder(); > GraphicsNode root = null; > > // Render the SVG image. > try { > root = builder.build(ctx, doc); > root.paint(graphics); > } catch (Exception e) { > e.printStackTrace(); > } > > return bufImg; > } > > Thanks in advance for your assistance! > > Warren W. Thompson > > Beer is proof that God loves us and wants us to be happy. > --Benjamin Franklin > > --------------------------------------------------------------------- > 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]