xmlgraphics-batik-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 37891] New: - ImageTranscoder always maintains aspect ratio even when both width / height are set
Date Tue, 13 Dec 2005 20:52:45 GMT
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: batik-dev@xmlgraphics.apache.org
        ReportedBy: steveshaw@ca.ibm.com


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: batik-dev-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-dev-help@xmlgraphics.apache.org


Mime
View raw message