DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=37891>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=37891

           Summary: ImageTranscoder always maintains aspect ratio even when
                    both width / height are set
           Product: Batik
           Version: 1.6
          Platform: Other
        OS/Version: other
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Utilities
        AssignedTo: [email protected]
        ReportedBy: [EMAIL PROTECTED]


JavaDoc for KEY_HEIGHT and KEY_WIDTH indicate that the aspect ratio is 
maintained if one of these 
values isn't set.  This is true except if you set both values, the aspect ratio 
of the rendered image is still 
maintained.  The buffered image will be created at the values suggested, but 
the SVG is rendered to fit 
within the size at the same aspect ratio as the original document.

I would expect that it would be rendered to the full extent of the width and 
height provided unless one 
of the values wasn't set.

This could be supported alternatively using a new key KEY_MAINTAIN_ASPECT ratio 
that is checked to 
see if rendering should always respect the original document aspect ratio.

i.e. code to calculate AffineTransform:

                boolean maintainAspectRatio = true;
                if (hints.containsKey(KEY_MAINTAIN_ASPECT_RATIO)) {
                        maintainAspectRatio = 
((Boolean)hints.get(KEY_MAINTAIN_ASPECT_RATIO)).booleanValue();
                }
                
                if (maintainAspectRatio) {
                        try {
                                Px = ViewBox.getViewTransform(ref, svgRoot, 
newWidth, newHeight);
                        } catch (BridgeException ex) {
                                throw new TranscoderException(ex);
                        }
                        
                        if (Px.isIdentity() && (newWidth != docWidth || 
newHeight != docHeight)) {
                                // The document has no viewBox, we need to 
resize it by hand.
                                // we want to keep the document size ratio
                                float d = Math.max(docWidth, docHeight);
                                float dd = Math.max(newWidth, newHeight);
                                float scale = dd/d;
                                Px = AffineTransform.getScaleInstance(scale, 
scale);
                        }
                }
                else {
                        float xscale = newWidth / docWidth;
                        float yscale = newHeight / docHeight; 
                        Px = AffineTransform.getScaleInstance(xscale, yscale);
                }

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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

Reply via email to