From b7ecb21cf6e5bb73f75046a9b73d83d33b6c23f0 Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Tue, 6 Sep 2005 09:34:55 +0000 Subject: [PATCH] Fix for SVG images with an intrinsic size when the FOUserAgent does not default to 72dpi. 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 --- .../org/apache/fop/image/analyser/SVGReader.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/java/org/apache/fop/image/analyser/SVGReader.java b/src/java/org/apache/fop/image/analyser/SVGReader.java index d7f433f3c..e627dbcdc 100644 --- a/src/java/org/apache/fop/image/analyser/SVGReader.java +++ b/src/java/org/apache/fop/image/analyser/SVGReader.java @@ -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) { -- 2.39.5