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 Piyush Rai <ra...@yahoo.com> on 2004/06/28 02:50:48 UTC
Saving JSVGCanvas images
Hi,
How can one get the image buffer currently being shown on JSVGCanvas? I need to save it as jpg/png OR send it to another application. Is there any method that returns the image buffer??
--Piyush.
---------------------------------
Do you Yahoo!?
Yahoo! Mail - Helps protect you from nasty viruses.
Re: NullPointerException while setting attributes
Posted by Thomas DeWeese <Th...@Kodak.com>.
Hi Piyush,
I think the problem is that the SVG attributes are in
the 'null' namespace not the SVG namespace (this is confusing
because the elements must be in the SVG namespace):
path[i].setAttributeNS(svgNS, "stroke",
namedNodes.getNamedItemNS(svgNS,"stroke").getNodeValue());
getNamedItemNS in this case is likely returning null.
Also as you might guess setting the 'svg:stroke"
attribute is not likely to have any effect on the display.
Piyush Rai wrote:
> Hi,
>
> I have a NodeList of path elements in an SVG file.
> String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
> NodeList paths = document.getElementsByTagNameNS(svgNS,"path");
>
> I am also creating an equal number of empty paths(by setting 'd'
> attribute as "").
>
> numberOfPaths = paths.getLength();
> path = new Element[numberOfPaths];
>
> Now I want to set other attributes of these new paths to that of
> original paths(from the SVG file itself, instead of constant values). I
> am trying this(for example, the "stroke" attribute):
> NamedNodeMap namedNodes = paths.item(i).getAttributes();
> //path[i].setAttributeNS(null, "stroke", "#00ffff"); THIS WORKS FINE
> path[i].setAttributeNS(svgNS,
> "stroke",namedNodes.getNamedItemNS(svgNS,"stroke").getNodeValue());
> And similarly for other attributes.
>
> But I am getting NullPointerException. All the statements are in the
> order as written here. What could be the reason! for this? Any thoughts?
> --Piyush.
>
> Do you Yahoo!?
> New and Improved Yahoo! Mail
> <http://us.rd.yahoo.com/mail_us/taglines/10/*http://promotions.yahoo.com/new_mail/static/efficiency.html>
> - Send 10MB messages!
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org
NullPointerException while setting attributes
Posted by Piyush Rai <ra...@yahoo.com>.
Hi,
I have a NodeList of path elements in an SVG file.
String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
NodeList paths = document.getElementsByTagNameNS(svgNS,"path");
I am also creating an equal number of empty paths(by setting 'd' attribute as "").
numberOfPaths = paths.getLength();
path = new Element[numberOfPaths];
Now I want to set other attributes of these new paths to that of original paths(from the SVG file itself, instead of constant values). I am trying this(for example, the "stroke" attribute):
NamedNodeMap namedNodes = paths.item(i).getAttributes();
//path[i].setAttributeNS(null, "stroke", "#00ffff"); THIS WORKS FINE
path[i].setAttributeNS(svgNS, "stroke",namedNodes.getNamedItemNS(svgNS,"stroke").getNodeValue());
And similarly for other attributes.
But I am getting NullPointerException. All the statements are in the order as written here. What could be the reason for this? Any thoughts?
--Piyush.
---------------------------------
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
Re: Saving JSVGCanvas images
Posted by Tonny Kohar <to...@kiyut.com>.
Hi,
> How can one get the image buffer currently being shown on JSVGCanvas?
> I need to save it as jpg/png OR send it to another application. Is
> there any method that returns the image buffer??
I think what you want is JSVGCanvas.getOffScreen(); it return
BufferedImage
Regards
Tonny Kohar
--
Sketsa
SVG Graphics Editor
http://www.kiyut.com
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org