com.twelvemonkeys.image
Class BufferedImageFactory

java.lang.Object
  extended by com.twelvemonkeys.image.BufferedImageFactory

public final class BufferedImageFactory
extends Object

A faster, lighter and easier way to convert an Image to a BufferedImage than using a PixelGrabber. Clients may provide progress listeners to monitor conversion progress.

Supports source image subsampling and source region extraction. Supports source images with 16 bit ColorModel and DataBuffer.TYPE_USHORT transfer type, without converting to 32 bit/TYPE_INT.

NOTE: Does not support images with more than one ColorModel or different types of pixel data. This is not very common.

Version:
$Id: //depot/branches/personal/haraldk/twelvemonkeys/release-2/twelvemonkeys-core/src/main/java/com/twelvemonkeys/image/BufferedImageFactory.java#1 $
Author:
Harald Kuhr

Nested Class Summary
static interface BufferedImageFactory.ProgressListener
          This interface allows clients of a BufferedImageFactory to receive notifications of decoding progress.
 
Constructor Summary
BufferedImageFactory(Image pSource)
          Creates a BufferedImageFactory.
BufferedImageFactory(ImageProducer pSource)
          Creates a BufferedImageFactory.
 
Method Summary
 void abort()
          Aborts the image production.
 void addProgressListener(BufferedImageFactory.ProgressListener pListener)
          Adds a progress listener to this factory.
 void dispose()
          Frees resources used by this BufferedImageFactory.
 BufferedImage getBufferedImage()
          Returns the BufferedImage extracted from the given ImageSource.
 ColorModel getColorModel()
          Returns the ColorModel extracted from the given ImageSource.
 void removeAllProgressListeners()
          Removes all progress listeners from this factory.
 void removeProgressListener(BufferedImageFactory.ProgressListener pListener)
          Removes a progress listener from this factory.
 void setSourceRegion(Rectangle pRegion)
          Sets the source region (AOI) for the new image.
 void setSourceSubsampling(int pXSub, int pYSub)
          Sets the source subsampling for the new image.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BufferedImageFactory

public BufferedImageFactory(Image pSource)
Creates a BufferedImageFactory.

Parameters:
pSource - the source image
Throws:
IllegalArgumentException - if pSource == null

BufferedImageFactory

public BufferedImageFactory(ImageProducer pSource)
Creates a BufferedImageFactory.

Parameters:
pSource - the source image producer
Throws:
IllegalArgumentException - if pSource == null
Method Detail

getBufferedImage

public BufferedImage getBufferedImage()
                               throws ImageConversionException
Returns the BufferedImage extracted from the given ImageSource. Multiple requests will return the same image.

Returns:
the BufferedImage
Throws:
ImageConversionException - if the given ImageSource cannot be converted for some reason.

getColorModel

public ColorModel getColorModel()
                         throws ImageConversionException
Returns the ColorModel extracted from the given ImageSource. Multiple requests will return the same model.

Returns:
the ColorModel
Throws:
ImageConversionException - if the given ImageSource cannot be converted for some reason.

dispose

public void dispose()
Frees resources used by this BufferedImageFactory.


abort

public void abort()
Aborts the image production.


setSourceRegion

public void setSourceRegion(Rectangle pRegion)
Sets the source region (AOI) for the new image.

Parameters:
pRegion - the source region

setSourceSubsampling

public void setSourceSubsampling(int pXSub,
                                 int pYSub)
Sets the source subsampling for the new image.

Parameters:
pXSub - horizontal subsampling factor
pYSub - vertical subsampling factor

addProgressListener

public void addProgressListener(BufferedImageFactory.ProgressListener pListener)
Adds a progress listener to this factory.

Parameters:
pListener - the progress listener

removeProgressListener

public void removeProgressListener(BufferedImageFactory.ProgressListener pListener)
Removes a progress listener from this factory.

Parameters:
pListener - the progress listener

removeAllProgressListeners

public void removeAllProgressListeners()
Removes all progress listeners from this factory.



Copyright © 2015. All Rights Reserved.