ach.image.tiff
Class TiffImageProducer

java.lang.Object
  extended byach.image.tiff.TiffImageProducer
All Implemented Interfaces:
java.awt.image.ImageProducer, java.lang.Runnable

public class TiffImageProducer
extends java.lang.Object
implements java.awt.image.ImageProducer, java.lang.Runnable

TiffImageProducer.java
Copyright (c) 1997-2000 Helge Hackbarth, All Rights Reserved.
Provides an image producer for platform independent TIFF images. Supports color depths of 1, 4, 8 and 24 bit. Image can be loaded asynchronously as separate thread or synchronously in conjunction with an EMemImageSource which will be faster for images with less than 8 bits per pixel as packed data are stored without conversion.

THE AUTHOR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. THE AUTHOR SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.


Constructor Summary
TiffImageProducer()
          Constructor for synchronous loading of a Tiff image.
TiffImageProducer(byte[] buf, int page)
          Constructor for asynchronous loading from byte array representing an image in Tiff format.
TiffImageProducer(java.net.URL context, java.lang.String name, int page)
          Constructor for asynchronous loading a Tiff image from either file or URL
 
Method Summary
 void addConsumer(java.awt.image.ImageConsumer ic)
          Adds an ImageConsumer to the list of consumers interested in data for this image.
 java.lang.String getErrorMsg()
          If image production completed with an error status the error message can be requested with this method.
 ImageInfo getImageInfo(java.lang.String fileName, int page)
          Get ImageInfo for a TIFF file from local file system
static java.awt.image.ImageProducer getImageProducer(byte[] imgFileBA, int page)
          Retrieve an EMemImageSource (extension of an ImageProducer) for a TIFF image from a byte array.
static java.awt.image.ImageProducer getImageProducer(java.lang.String name, int page)
          Retrieve an EMemImageSource (extension of an ImageProducer) for a TIFF image from a (local) file.
static java.awt.image.ImageProducer getImageProducer(java.net.URL context, int page)
          Retrieve an EMemImageSource (extension of an ImageProducer) for a TIFF image from an URL.
static java.awt.image.ImageProducer getImageProducer(java.net.URL context, java.lang.String name, int page)
          Retrieve an EMemImageSource (extension of an ImageProducer) for a TIFF image from an URL or file (either the context or the name parameter must be null).
 boolean isConsumer(java.awt.image.ImageConsumer ic)
          Determine if an ImageConsumer is on the list of consumers currently interested in data for this image.
 void removeConsumer(java.awt.image.ImageConsumer ic)
          Remove an ImageConsumer from the list of consumers interested in data for this image.
 void requestTopDownLeftRightResend(java.awt.image.ImageConsumer ic)
          Requests that a given ImageConsumer have the image data delivered one more time in top-down, left-right order.
static void reverseBitOrder(byte[] buffer, int off, int count)
          reverse the bit order for each byte in a buffer starting from offset
 void run()
          The TiffImageProducer is automatically started as separate thread when startProduction was called for an image consumer.
 void startProduction(java.awt.image.ImageConsumer ic)
          Adds an ImageConsumer to the list of consumers interested in data for this image, and immediately start delivery of the image data through the ImageConsumer interface.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TiffImageProducer

public TiffImageProducer()
Constructor for synchronous loading of a Tiff image. Only internally used by the static method getImageProducer which will return an ImageProducer after the images is loaded completely into a ach.image.MemoryimageSource. See ImageInfo class source for usage.


TiffImageProducer

public TiffImageProducer(java.net.URL context,
                         java.lang.String name,
                         int page)
Constructor for asynchronous loading a Tiff image from either file or URL

Parameters:
context - the URL of an image (null if loaded from local file system)
name - pathname if load from local file system
page - allows to load a particular page of a multi page tiff file

TiffImageProducer

public TiffImageProducer(byte[] buf,
                         int page)
Constructor for asynchronous loading from byte array representing an image in Tiff format.

Parameters:
buf - an array of bytes representing the image data in Tiff format
page - allows to load a particular page of a multi page tiff file
Method Detail

getImageInfo

public ImageInfo getImageInfo(java.lang.String fileName,
                              int page)
                       throws java.io.IOException,
                              UnknownFileFormatException
Get ImageInfo for a TIFF file from local file system

Parameters:
fileName - specifying the path to the TIFF file
page - allows to access a particular page for multipage TIFF files
Throws:
java.io.IOException
UnknownFileFormatException

reverseBitOrder

public static void reverseBitOrder(byte[] buffer,
                                   int off,
                                   int count)
reverse the bit order for each byte in a buffer starting from offset

Parameters:
buffer - containing the bytes to be reversed
off - offset to start from
count - number of bytes to be processed

getImageProducer

public static java.awt.image.ImageProducer getImageProducer(java.net.URL context,
                                                            java.lang.String name,
                                                            int page)
                                                     throws java.awt.AWTException
Retrieve an EMemImageSource (extension of an ImageProducer) for a TIFF image from an URL or file (either the context or the name parameter must be null). Returns after the image is completely loaded to memory (synchronously).

Parameters:
context - contains the URL.
name - contains the file name if loaded from local file system
page - contains page (may be > 1 for multi document images)
Throws:
java.awt.AWTException - on stream or bitmap data errors

getImageProducer

public static java.awt.image.ImageProducer getImageProducer(java.lang.String name,
                                                            int page)
                                                     throws java.awt.AWTException
Retrieve an EMemImageSource (extension of an ImageProducer) for a TIFF image from a (local) file. Returns after the image is completely loaded to memory (synchronously).

Parameters:
name - contains the file name.
page - contains page (may be > 1 for multi document images)
Throws:
java.awt.AWTException - on stream or bitmap data errors

getImageProducer

public static java.awt.image.ImageProducer getImageProducer(java.net.URL context,
                                                            int page)
                                                     throws java.awt.AWTException
Retrieve an EMemImageSource (extension of an ImageProducer) for a TIFF image from an URL. Returns after the image is completely loaded to memory (synchronously).

Parameters:
page - contains page (may be > 1 for multi document images)
Throws:
java.awt.AWTException - on stream or bitmap data errors

getImageProducer

public static java.awt.image.ImageProducer getImageProducer(byte[] imgFileBA,
                                                            int page)
                                                     throws java.awt.AWTException
Retrieve an EMemImageSource (extension of an ImageProducer) for a TIFF image from a byte array. Returns after the image is completely loaded to memory (synchronously).

Parameters:
imgFileBA - contains the file as byte array
page - contains page (may be > 1 for multi document images)
Throws:
java.awt.AWTException - on stream or bitmap data errors

addConsumer

public void addConsumer(java.awt.image.ImageConsumer ic)
Adds an ImageConsumer to the list of consumers interested in data for this image.

Specified by:
addConsumer in interface java.awt.image.ImageProducer
See Also:
ImageConsumer

run

public void run()
The TiffImageProducer is automatically started as separate thread when startProduction was called for an image consumer. You do not need to call run yourself.

Specified by:
run in interface java.lang.Runnable

isConsumer

public boolean isConsumer(java.awt.image.ImageConsumer ic)
Determine if an ImageConsumer is on the list of consumers currently interested in data for this image.

Specified by:
isConsumer in interface java.awt.image.ImageProducer
Returns:
true if the ImageConsumer is on the list; false otherwise
See Also:
ImageConsumer

removeConsumer

public void removeConsumer(java.awt.image.ImageConsumer ic)
Remove an ImageConsumer from the list of consumers interested in data for this image.

Specified by:
removeConsumer in interface java.awt.image.ImageProducer
See Also:
ImageConsumer

startProduction

public void startProduction(java.awt.image.ImageConsumer ic)
Adds an ImageConsumer to the list of consumers interested in data for this image, and immediately start delivery of the image data through the ImageConsumer interface.

Specified by:
startProduction in interface java.awt.image.ImageProducer
See Also:
ImageConsumer

requestTopDownLeftRightResend

public void requestTopDownLeftRightResend(java.awt.image.ImageConsumer ic)
Requests that a given ImageConsumer have the image data delivered one more time in top-down, left-right order.

Specified by:
requestTopDownLeftRightResend in interface java.awt.image.ImageProducer
See Also:
ImageConsumer

getErrorMsg

public java.lang.String getErrorMsg()
If image production completed with an error status the error message can be requested with this method.

Returns:
the error message if completed with error status