diff options
author | Jeremias Maerki <jeremias@apache.org> | 2006-07-21 15:01:17 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2006-07-21 15:01:17 +0000 |
commit | 7ede95ce494fab902d8b23d043bc84b921280af5 (patch) | |
tree | 1cf35e23da9408e4aca1710f633e85a71219a152 /src/java/org/apache/fop/fo/flow | |
parent | 1c72c2ed05b0b785da7ceb0218edd342c7c937c4 (diff) | |
download | xmlgraphics-fop-7ede95ce494fab902d8b23d043bc84b921280af5.tar.gz xmlgraphics-fop-7ede95ce494fab902d8b23d043bc84b921280af5.zip |
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
Diffstat (limited to 'src/java/org/apache/fop/fo/flow')
-rw-r--r-- | src/java/org/apache/fop/fo/flow/ExternalGraphic.java | 19 |
1 files changed, 7 insertions, 12 deletions
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; } } |