ach.image.bmp
Class BmpImageProducer

java.lang.Object
  extended byach.image.bmp.BmpImageProducer
All Implemented Interfaces:
java.awt.image.ImageProducer, java.lang.Runnable

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

BmpImageProducer.java
Copyright (c) 1997, 1998 Helge Hackbarth, All Rights Reserved.
Provides an image producer for BMP images (Windows and OS/2 style). 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
BmpImageProducer(java.lang.String name)
          Constructor for BmpImageProducer called by getImageProducer()
BmpImageProducer(java.net.URL context, java.lang.String name)
          Constructor for BmpImageProducer called by getImageProducer()
 
Method Summary
 void addConsumer(java.awt.image.ImageConsumer ic)
          Adds an ImageConsumer to the list of consumers interested in data for this image.
 java.awt.image.ImageProducer extractImage(java.io.DataInputStream is)
          Given an input stream, create an ImageProducer from the BMP info contained in the stream.
 java.lang.String getErrorMsg()
          If image production completed with an error status the error message can be requested with this method.
static java.awt.image.ImageProducer getImageProducer(java.lang.String name)
          Retrieve an ImageProducer for a BMP.
static java.awt.image.ImageProducer getImageProducer(java.net.URL context)
          Retrieve an ImageProducer given just a BMP URL.
static java.awt.image.ImageProducer getImageProducer(java.net.URL context, java.lang.String name)
          Retrieve an ImageProducer for a BMP URL.
 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
 void run()
          The BmpImageProducer 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.
 java.lang.String toString()
          Describe the image as a string
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BmpImageProducer

public BmpImageProducer(java.lang.String name)
Constructor for BmpImageProducer called by getImageProducer()

Parameters:
name - local file name of image

BmpImageProducer

public BmpImageProducer(java.net.URL context,
                        java.lang.String name)
Constructor for BmpImageProducer called by getImageProducer()

Parameters:
name - name of image file (to be appended to URL)
Method Detail

extractImage

public java.awt.image.ImageProducer extractImage(java.io.DataInputStream is)
                                          throws java.awt.AWTException
Given an input stream, create an ImageProducer from the BMP info contained in the stream.

Parameters:
is - contains the input stream to use
Throws:
java.awt.AWTException - on stream or bitmap data errors

toString

public java.lang.String toString()
Describe the image as a string


getImageProducer

public static java.awt.image.ImageProducer getImageProducer(java.lang.String name)
                                                     throws java.awt.AWTException
Retrieve an ImageProducer for a BMP.

Parameters:
name - contains the file name.
Throws:
java.awt.AWTException - on stream or bitmap data errors

getImageProducer

public static java.awt.image.ImageProducer getImageProducer(java.net.URL context,
                                                            java.lang.String name)
                                                     throws java.awt.AWTException
Retrieve an ImageProducer for a BMP URL.

Parameters:
context - contains the base URL (from getCodeBase() or such)
name - contains the file name.
Throws:
java.awt.AWTException - on stream or bitmap data errors

getImageProducer

public static java.awt.image.ImageProducer getImageProducer(java.net.URL context)
                                                     throws java.awt.AWTException
Retrieve an ImageProducer given just a BMP URL.

Parameters:
context - contains the base URL (from getCodeBase() or such)
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 BmpImageProducer 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. * @see ImageConsumer

Specified by:
requestTopDownLeftRightResend in interface java.awt.image.ImageProducer

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