Hi Thomas,

(Apologies for this long email....)

Sorry for the delay in replying, I've been trying out some things to see if
I can understand what is happening here. I previously was able to export to
JPG, so obviously some code change I have made in the last two weeks has
broken it. One change I made was to attempt to assign correct namespaces to
the document and its elements, so it may be something to do with that?
(Although that may be a red herring..)

I've attached a complete SVG file which gives the stack trace as first
reported. (If you want to actually view the SVG, you'll need my style sheet
too, let me know if that's helpful and I can send on).

Another thing that puzzles me is that using the same code I am able to
produce another SVG document (containing different Elements) which exports
to JPEG fine. Basicallly we are creating a graphing application... my
histogram (containing SVG defined Rects) renders fine, my scatter plot
(containing my own definition of #circle) does not. 

--------------------------------------------------------------------

I define my circle like this:

                Element circle_light =
doc.createElementNS(Config.SVG_NAMESPACE,
                                SVG12Constants.SVG_PATH_TAG);
                circle_light.setAttribute("id", CIRCLE_BLANK);
                circle_light.setAttribute("stroke-width", "0.2");
                circle_light.setAttribute("fill", "white");
                circle_light.setAttribute("d", "M0.4,-0.4 a0.7,0.7 0 0.7,0
0.1,0.1 z");
                defs.appendChild(circle_light); 

--------------------------------------------------------------------

I specify my namespace like this, then refer to it using my variable
throughout my code:

        public static final String SVG_NAMESPACE =
SVGDOMImplementation.SVG_NAMESPACE_URI;

I assign the namespace both to the document, and to the elements I create
within it. Is that correct?

---------------------------------------------------------------------


The method I use to stream is this:

        public void streamSVGIntoImageFormat(SVGDocument doc, String
mimeType) {
                try {
                        ImageTranscoder t = null;
                        if (mimeType.equals(Config.JPEG)) {
                                t = new JPEGTranscoder();
        
t.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, new Float(.8));
                        } else if (mimeType.equals(Config.PNG)) {
                                t = new PNGTranscoder();
                        } else if (mimeType.equals(Config.TIFF)) {
                                t = new TIFFTranscoder();
                        } else {
                                logger.error("ERROR: A request to stream an
image was recieved with an unsupported mime type: "
                                                + mimeType);
                                return;
                        }
                        TranscoderInput input = new TranscoderInput(doc);
                        OutputStream ostream = new
FileOutputStream("c:\\out." + mimeType);
                        TranscoderOutput output = new
TranscoderOutput(ostream);
                        t.transcode(input, output);
                        ostream.flush();
                        ostream.close();
                        byte[] bytes = getBytesFromFile(new File("c:\\out."
+ mimeType));
                        context.setAttribute("jpegbytes", bytes);
                        context.setAttribute("mimeType", mimeType);
                } catch (Exception e) {
                        e.printStackTrace();
                        logger.error("Error in streaming SVG because " +
e.getMessage(), e.getCause());
                }
        }

------------------------------------------------------------------------

Thanks in advance for any help, this one has got me puzzled.

Kind regards,
Dylan

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: 21 May 2006 18:51
To: [email protected]
Cc: [email protected]
Subject: Re: Export to JPG error

Hi Dylan,

The single element looks ok, can you provide a complete example that shows 
the problem?
Also do you get this problem with the included svgrasterizer application 
or just your
'stream' application?


"Dylan Browne" <[EMAIL PROTECTED]> wrote on 05/19/2006 10:41:58 
AM:

> I'm getting an error when attempting to export an SVG Document to JPEG 
(or
> other image format). I've included the top of the stack trace below.
> Basically the essence of the error is that:
> 
> The attribute "xlink:href" of the element <use> is required
> 
> <use fill-opacity="0.2" xmlns:xlink="http://www.w3.org/1999/xlink";
> 
> onmousedown="select_group(evt,true,90.6912,202.90311885986404);"
>                  stroke="blue" xlink:href="#circle"
> 
> onmouseover="select_point(evt,true,90.6912,202.90311885986404, 
&apos;DOSE =
> 0.00&apos;,&apos;IRESP =
> 106.89&apos;,&apos;ID&apos;,&apos;1.0&apos;,0.0,106.88575287553);"
> transform="translate(90.6912,202.90311885986404)scale(5.0)"
>                  width="5.0%" xlink:show="embed" xlink:type="simple"
> fill="blue"
>                  onmouseup="deselect_group(evt,true);" height="5.0%"
> 
> onmouseout="deselect_point(evt,true);deselect_group(evt,true);"
>                  xlink:actuate="onLoad"/>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Attachment: svgFailsToConvertToJPG.svg
Description: image/svg

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to