]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Fix for SVG images with an intrinsic size when the FOUserAgent does not default to...
authorJeremias Maerki <jeremias@apache.org>
Tue, 6 Sep 2005 09:34:55 +0000 (09:34 +0000)
committerJeremias Maerki <jeremias@apache.org>
Tue, 6 Sep 2005 09:34:55 +0000 (09:34 +0000)
Round the intrinsic size, don't truncate it.

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@278957 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/image/analyser/SVGReader.java

index d7f433f3cc0af41236efe307aa9fbf1333fe1da3..e627dbcdc3d7c3a755d9ab0cc7921b6bd919cb3a 100644 (file)
@@ -166,6 +166,10 @@ public class SVGReader implements ImageReader {
 
                 FopImage.ImageInfo info = new FopImage.ImageInfo();
 
+                //Set the resolution to that of the FOUserAgent
+                info.dpiHorizontal = 25.4f / pixelUnitToMM;
+                info.dpiVertical = info.dpiHorizontal;
+                
                 info.originalURI = uri;
                 info.mimeType = getMimeType();
                 info.str = SVGDOMImplementation.SVG_NAMESPACE_URI;
@@ -182,8 +186,7 @@ public class SVGReader implements ImageReader {
                 SVGUserAgent userAg = new SVGUserAgent(pixelUnitToMM,
                             new AffineTransform());
                 BridgeContext ctx = new BridgeContext(userAg);
-                UnitProcessor.Context uctx =
-                        UnitProcessor.createContext(ctx, e);
+                UnitProcessor.Context uctx = UnitProcessor.createContext(ctx, e);
 
                 // 'width' attribute - default is 100%
                 s = e.getAttributeNS(null,
@@ -191,8 +194,8 @@ public class SVGReader implements ImageReader {
                 if (s.length() == 0) {
                     s = SVGOMDocument.SVG_SVG_WIDTH_DEFAULT_VALUE;
                 }
-                info.width = (int) UnitProcessor.svgHorizontalLengthToUserSpace(
-                        s, SVGOMDocument.SVG_WIDTH_ATTRIBUTE, uctx);
+                info.width = Math.round(UnitProcessor.svgHorizontalLengthToUserSpace(
+                        s, SVGOMDocument.SVG_WIDTH_ATTRIBUTE, uctx));
 
                 // 'height' attribute - default is 100%
                 s = e.getAttributeNS(null,
@@ -200,8 +203,8 @@ public class SVGReader implements ImageReader {
                 if (s.length() == 0) {
                     s = SVGOMDocument.SVG_SVG_HEIGHT_DEFAULT_VALUE;
                 }
-                info.height = (int) UnitProcessor.svgVerticalLengthToUserSpace(
-                        s, SVGOMDocument.SVG_HEIGHT_ATTRIBUTE, uctx);
+                info.height = Math.round(UnitProcessor.svgVerticalLengthToUserSpace(
+                        s, SVGOMDocument.SVG_HEIGHT_ATTRIBUTE, uctx));
 
                 return info;
             } catch (NoClassDefFoundError ncdfe) {