You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Guillaume Rosauro <g....@gmail.com> on 2007/05/23 14:54:06 UTC

How to use Filters?

Hi,


I am quite lost with Batik and specially with filters.
I try to add a filter after a drawImage but I do not think that's the right
way to achieve this. What should I do ?

Code :

//creating DOM and SVGGraphics
DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
String namespaceURI = SVGDOMImplementation.SVG_NAMESPACE_URI;
Document doc = impl.createDocument(namespaceURI, "svg", null);
SVGGraphics2D svgGraphics = new SVGGraphics2D(doc);

//first image (background Image)
BufferedImage bufImg = ImageIO.read(new File("bgImage.png"));
svgGraphics.drawImage(bufImg, 0, 0, null);
doc.setAttributeNS(null, "width", Integer.toString(bufImg.getWidth()));
doc.setAttributeNS(null, "height", Integer.toString(bufImg.getHeight()));

//add a copyright image on background
BufferedImage bufImgCopyRight = ImageIO.read(img);
svgGraphics.drawImage(bufImgCopyRight, x, y, null);

//TODO : here a filter should be applied
//to add shadow on this element (copyright image)
//HOW TO RETRIEVE THE LAST ELEMENT ????

doc.appendChild(svgGraphics.getRoot());
//Transcode and save



Thanks,


Guillaume.

Re: How to use Filters?

Posted by th...@kodak.com.
Hi Guillaume,

"Guillaume Rosauro" <g....@gmail.com> wrote on 05/23/2007 08:54:06 AM:

> I am quite lost with Batik and specially with filters. 
> I try to add a filter after a drawImage but I do not think that's 
> the right way to achieve this. What should I do ?

   Unfortunately it is difficult to mix SVGGraphics2D drawing 
with manual manipulation of the DOM (like adding a filter). 
The best you can do is call 'svgGraphics.getRoot()' and 
walk the returned DOM tree to find the 'last' graphic element 
(in your case an svg:image element).  Once you have that you 
can add your 'filter' attribute.



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