You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by Eriksson John <jo...@wmdata.com> on 2002/06/20 11:08:00 UTC

Is this possible to do in an easy way?!?!?

What I'm trying to do is rather simple but I just can't figure out 
how to do it.

This is what I need to do:

1. Load one or more SVG images.
2. Load one or more bitmap images (like gif or jpeg)
3. Create an BufferedImage
4. Draw the SVG images and the bitmap images to the BufferedImage on
   diffrent locations.

All examples I've found is about displaying SVGs in JSVGCanvas or
converting SCGs to other file formats.

HELP!

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org


Re: Is this possible to do in an easy way?!?!?

Posted by Thomas E Deweese <th...@kodak.com>.
>>>>> "VH" == Vincent Hardy <vi...@sun.com> writes:

VH> Hello, You can do something like:

    Yes, you might also take a look at the slideshow app, as it
renders everything to a buffered image before displaying it.  The
interesting bit for you is in the RenderThread.

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org


Re: Is this possible to do in an easy way?!?!?

Posted by Vincent Hardy <vi...@sun.com>.
Hello,

You can do something like:


import org.apache.batik.util.XMLResourceDescriptor;
import org.apache.batik.dom.svg.SAXSVGDocuemntFactory;
import org.apache.batik.bridge.UserAgent;
import org.apache.batik.bridge.GVTBuilder;
import org.apache.batik.bridge.BridgeException;
import org.apache.batik.gvt.GraphicsNode;

import java.awt.Graphics2D;
import java.awt.image.BufferedImage;

import org.w3c.dom.Document;
....

// Load the SVG Document 
String parserClassName = XMLResourceDescriptor.getXMLParserClassName();
SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parserClassName);
Document doc = null;

try {
    doc = f.createDocument(svgURL);
} catch(IOException e){
    ....
}

UserAgent userAgent = ....; 
    // e.g. org.apache.batik.bridge.UserAgentAdapter
GVTBuilder builder = new GVTBuilder();
BridgeContext ctx = new BridgeContext(userAgent);
GraphicsNode gn = null;
try {
    gn = builder.build(ctx, doc);
} catch (BridgeException e){
    ...
    
} 

BufferedImage buf = new BufferedImage(...);
Graphics2D g = buf.createGraphics();

g.draw(...);
gn.paint();

I hope this helps,
Cheers,
Vincent.

Eriksson John wrote:
> 
> What I'm trying to do is rather simple but I just can't figure out
> how to do it.
> 
> This is what I need to do:
> 
> 1. Load one or more SVG images.
> 2. Load one or more bitmap images (like gif or jpeg)
> 3. Create an BufferedImage
> 4. Draw the SVG images and the bitmap images to the BufferedImage on
>    diffrent locations.
> 
> All examples I've found is about displaying SVGs in JSVGCanvas or
> converting SCGs to other file formats.
> 
> HELP!
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-dev-help@xml.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org