xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thomas.dewe...@kodak.com
Subject Re: Export jpeg/tif/png saves only visible area of the image
Date Thu, 11 May 2006 00:28:05 GMT
Hi Sudhakar,

Sudhakar S <yessudhakar@hotmail.com> wrote on 05/10/2006 10:08:29 AM:

But can i use available document instead of cloned document?

   If you use the document in the Canvas all dynamic links will be broken
when the Transcoder builds it's GVT tree (the document will become 
associated
with the Transcoders GVT tree not the Canvas's tree).

> Now i can able to export jpeg/tif/png based on the width and height i 
used.
> But here i didnt use cloned document. because while using cloned 
document, i
> am getting following exception. i used
> "DOMUtilities.deepCloneDocument(svgCanvas.getSVGDocument(), impl)" to 
clone
> the document. 

    What code are you running?  The line numbers below don't match up
with trunk, svg11, or the Batik 1.6 release. In fact none of them call
'getCurrentScale' - is this locally modified code?
 
> java.lang.NullPointerException
> 
org.apache.batik.dom.svg.SVGOMSVGElement.getCurrentScale(SVGOMSVGElement.java:222)
> 
org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(SVGAbstractTranscoder.java:296)

> While calculating height and width, it returns wrong coordinates. so i
> couldn't save the full scaled image. so can you please explain how to
> calculate scaled image size? I used the following way to calculate width 
and
> height.
> 
> Rectangle canvasRect = svgCanvas.getBounds(); 

    You don't care what the canvas's width/height are you care
what the viewBox on the root SVG element is.  The method
batik.swing.JSVGScrollPane.getViewBoxRect() is a pretty good example
of how to get this rect.

> AffineTransform att = svgCanvas.getRenderingTransform(); 
> AffineTransform itrans = att.createInverse(); 

    You just want to use: 
        itrans = canvas.getViewBoxTransform()

> Rectangle rect = itrans.createTransformedShape(canvasRect).getBounds();

   This is good.

> double w = rect.getWidth() * docWidth; 
> double h = rect.getHeight() * docHeight; 

   What the heck is docWidth??? ;)
   If you do the above you should be able to just use rect.width/height.
 

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


Mime
View raw message