From de0749af71e5d7822ac7febadca6122f3efe7da8 Mon Sep 17 00:00:00 2001 From: eschaeffer Date: Wed, 24 May 2000 10:41:24 +0000 Subject: [PATCH] ImageConsumer correction git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193384 13f79535-47bb-0310-9956-ffa450edef68 --- src/org/apache/fop/image/JimiImage.java | 46 ++++++++++++++++++------- 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/src/org/apache/fop/image/JimiImage.java b/src/org/apache/fop/image/JimiImage.java index 681e7549a..37f5f843e 100644 --- a/src/org/apache/fop/image/JimiImage.java +++ b/src/org/apache/fop/image/JimiImage.java @@ -61,7 +61,7 @@ import org.apache.fop.pdf.PDFFilter; // Java import java.util.Hashtable; import java.net.URL; -import java.io.*; +import java.io.IOException; //import java.io.PrintWriter; import java.awt.image.*; import java.awt.*; @@ -96,10 +96,10 @@ public class JimiImage implements FopImage { int[] tmpMap = null; try { ImageProducer ip = Jimi.getImageProducer(this.m_href.openStream(), Jimi.SYNCHRONOUS | Jimi.IN_MEMORY); - FopImageConsumer consumer = new FopImageConsumer(this); + FopImageConsumer consumer = new FopImageConsumer(); ip.startProduction(consumer); - while (! consumer.isImageReady() ) {} + while (! consumer.isImageReady()) {} this.m_height = consumer.getHeight(); this.m_width = consumer.getWidth(); @@ -232,25 +232,47 @@ public class JimiImage implements FopImage { } // CONSUMER CLASS - public static class FopImageConsumer implements ImageConsumer { + public class FopImageConsumer implements ImageConsumer { int width = -1; int height = -1; - JimiImage graphic; Integer imageStatus = new Integer(-1); - public FopImageConsumer(JimiImage graphic) { - this.graphic = graphic; + public FopImageConsumer() { } public void imageComplete(int status) { - synchronized (this.imageStatus) { - this.imageStatus = new Integer(status); + synchronized(this.imageStatus) { + // Need to stop status if image done + if (this.imageStatus.intValue() != ImageConsumer.STATICIMAGEDONE) + this.imageStatus = new Integer(status); } +/* +System.err.print("Status "); +if (status == ImageConsumer.COMPLETESCANLINES) { + System.err.println("CompleteScanLines"); +} else if (status == ImageConsumer.IMAGEABORTED) { + System.err.println("ImageAborted"); +} else if (status == ImageConsumer.IMAGEERROR) { + System.err.println("ImageError"); +} else if (status == ImageConsumer.RANDOMPIXELORDER) { + System.err.println("RandomPixelOrder"); +} else if (status == ImageConsumer.SINGLEFRAME) { + System.err.println("SingleFrame"); +} else if (status == ImageConsumer.SINGLEFRAMEDONE) { + System.err.println("SingleFrameDone"); +} else if (status == ImageConsumer.SINGLEPASS) { + System.err.println("SinglePass"); +} else if (status == ImageConsumer.STATICIMAGEDONE) { + System.err.println("StaticImageDone"); +} else if (status == ImageConsumer.TOPDOWNLEFTRIGHT) { + System.err.println("TopDownLeftRight"); +} +*/ } - public synchronized boolean isImageReady() + public boolean isImageReady() throws Exception { - synchronized (this.imageStatus) { + synchronized(this.imageStatus) { if ( this.imageStatus.intValue() != -1 ) { String statusStr = null; if ( this.imageStatus.intValue() == ImageConsumer.IMAGEABORTED ) { @@ -261,7 +283,7 @@ public class JimiImage implements FopImage { if ( statusStr != null ) { throw new Exception("Error in image consumer (" + statusStr + ")"); } - + if ( this.imageStatus.intValue() == ImageConsumer.STATICIMAGEDONE ) { return true; } -- 2.39.5