From 7ede95ce494fab902d8b23d043bc84b921280af5 Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Fri, 21 Jul 2006 15:01:17 +0000 Subject: Fixed two memory-leaks in image handling (ImageFactory and ExternalGraphic). The image cache is finally working properly. Currently implemented without the cleanup thread as done by Batik. Added ImageIO provider for handling PNG in addition to the internal codec. ImageIO proved to be faster and less memory-intensive for PNGs. ImageIO takes precedence of the internal codec. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@424349 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/fo/flow/ExternalGraphic.java | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'src/java/org/apache/fop/fo/flow') diff --git a/src/java/org/apache/fop/fo/flow/ExternalGraphic.java b/src/java/org/apache/fop/fo/flow/ExternalGraphic.java index d80cbe868..a84256b46 100644 --- a/src/java/org/apache/fop/fo/flow/ExternalGraphic.java +++ b/src/java/org/apache/fop/fo/flow/ExternalGraphic.java @@ -41,7 +41,8 @@ public class ExternalGraphic extends AbstractGraphics { //Additional values private String url; - private FopImage fopimage; + private int intrinsicWidth; + private int intrinsicHeight; /** * Create a new External graphic node. @@ -63,7 +64,7 @@ public class ExternalGraphic extends AbstractGraphics { url = ImageFactory.getURL(getSrc()); FOUserAgent userAgent = getUserAgent(); ImageFactory fact = userAgent.getFactory().getImageFactory(); - fopimage = fact.getImage(url, userAgent); + FopImage fopimage = fact.getImage(url, userAgent); if (fopimage == null) { getLogger().error("Image not available: " + getSrc()); } else { @@ -71,6 +72,8 @@ public class ExternalGraphic extends AbstractGraphics { if (!fopimage.load(FopImage.DIMENSIONS)) { getLogger().error("Cannot read image dimensions: " + getSrc()); } + this.intrinsicWidth = fopimage.getIntrinsicWidth(); + this.intrinsicHeight = fopimage.getIntrinsicHeight(); } //TODO Report to caller so he can decide to throw an exception } @@ -122,22 +125,14 @@ public class ExternalGraphic extends AbstractGraphics { * @see org.apache.fop.fo.flow.AbstractGraphics#getIntrinsicWidth() */ public int getIntrinsicWidth() { - if (fopimage != null) { - return fopimage.getIntrinsicWidth(); - } else { - return 0; - } + return this.intrinsicWidth; } /** * @see org.apache.fop.fo.flow.AbstractGraphics#getIntrinsicHeight() */ public int getIntrinsicHeight() { - if (fopimage != null) { - return fopimage.getIntrinsicHeight(); - } else { - return 0; - } + return this.intrinsicHeight; } } -- cgit v1.2.3