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 hardc0d3r <ha...@gmail.com> on 2007/05/11 18:06:32 UTC

Re: Error importing Images into an image tag?

from what i understand, if my image is in the same folder as my program, i
only need to specify the filename. but i get a null pointer exception.. i am
sure that the image and the program is on the same folder.. here is the
code:

private void loadImage() {
    	try {
    		SVGDocument doc = svgCanvas.getSVGDocument();
            
            Element mapLayer = doc.createElementNS(svgNS, "image");
            imageLayer.setAttributeNS(null, "x", "0");
            imageLayer.setAttributeNS(null, "y", "0");
            imageLayer.setAttributeNS(null, "width", "260");
            imageLayer.setAttributeNS(null, "height", "368");
            imageLayer.setAttributeNS(XLINK_NAMESPACE_URI, "xlink:href",
"test.jpg");
            
            svgRoot.appendChild(imageLayer);
            
    	} catch(Exception e) {
    		System.out.println(e.toString());
    	}
    }

are ther any errors on the code?
-- 
View this message in context: http://www.nabble.com/Error-importing-Images-into-an-image-tag--tf646195.html#a10434915
Sent from the Batik - Users mailing list archive at Nabble.com.


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


Re: Error importing Images into an image tag?

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

hardc0d3r <ha...@gmail.com> wrote on 05/11/2007 12:06:32 PM:

> from what i understand, if my image is in the same folder as my program, 
i
> only need to specify the filename.

   I don't know why you would think that.  Your images need to
be in the same folder as the document you are adding the image
elements to.  If your document is created entirely on the fly
then it probably doesn't have a 'base URL'.  You can associate
one by calling batik.dom.svg.SVGOMDocument.setURLObject(URL).

 but i get a null pointer exception.. i am
> sure that the image and the program is on the same folder.. here is the
> code:
> 
> private void loadImage() {
>        try {
>           SVGDocument doc = svgCanvas.getSVGDocument();
> 
>             Element mapLayer = doc.createElementNS(svgNS, "image");
>             imageLayer.setAttributeNS(null, "x", "0");
>             imageLayer.setAttributeNS(null, "y", "0");
>             imageLayer.setAttributeNS(null, "width", "260");
>             imageLayer.setAttributeNS(null, "height", "368");
>             imageLayer.setAttributeNS(XLINK_NAMESPACE_URI, "xlink:href",
> "test.jpg");
> 
>             svgRoot.appendChild(imageLayer);
> 
>        } catch(Exception e) {
>           System.out.println(e.toString());
>        }
>     }
> 
> are ther any errors on the code?
> -- 
> View this message in context: http://www.nabble.com/Error-importing-
> Images-into-an-image-tag--tf646195.html#a10434915
> Sent from the Batik - Users mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 


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