From: eschaeffer Date: Wed, 24 May 2000 10:41:24 +0000 (+0000) Subject: ImageConsumer correction X-Git-Tag: pre-columns~493 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=de0749af71e5d7822ac7febadca6122f3efe7da8;p=xmlgraphics-fop.git ImageConsumer correction git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193384 13f79535-47bb-0310-9956-ffa450edef68 --- 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; }