Package com.twelvemonkeys.image
Class BufferedImageFactory
- java.lang.Object
-
- com.twelvemonkeys.image.BufferedImageFactory
-
public final class BufferedImageFactory extends java.lang.Object
A faster, lighter and easier way to convert anImage
to aBufferedImage
than using aPixelGrabber
. Clients may provide progress listeners to monitor conversion progress.Supports source image subsampling and source region extraction. Supports source images with 16 bit
ColorModel
andDataBuffer.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
Nested Classes Modifier and Type Class Description static interface
BufferedImageFactory.ProgressListener
This interface allows clients of aBufferedImageFactory
to receive notifications of decoding progress.
-
Constructor Summary
Constructors Constructor Description BufferedImageFactory(java.awt.Image pSource)
Creates aBufferedImageFactory
.BufferedImageFactory(java.awt.image.ImageProducer pSource)
Creates aBufferedImageFactory
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
abort()
Aborts the image production.void
addProgressListener(BufferedImageFactory.ProgressListener pListener)
Adds a progress listener to this factory.void
dispose()
Frees resources used by thisBufferedImageFactory
.java.awt.image.BufferedImage
getBufferedImage()
Returns theBufferedImage
extracted from the givenImageSource
.java.awt.image.ColorModel
getColorModel()
Returns theColorModel
extracted from the givenImageSource
.void
removeAllProgressListeners()
Removes all progress listeners from this factory.void
removeProgressListener(BufferedImageFactory.ProgressListener pListener)
Removes a progress listener from this factory.void
setSourceRegion(java.awt.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.
-
-
-
Constructor Detail
-
BufferedImageFactory
public BufferedImageFactory(java.awt.Image pSource)
Creates aBufferedImageFactory
.- Parameters:
pSource
- the source image- Throws:
java.lang.IllegalArgumentException
- ifpSource == null
-
BufferedImageFactory
public BufferedImageFactory(java.awt.image.ImageProducer pSource)
Creates aBufferedImageFactory
.- Parameters:
pSource
- the source image producer- Throws:
java.lang.IllegalArgumentException
- ifpSource == null
-
-
Method Detail
-
getBufferedImage
public java.awt.image.BufferedImage getBufferedImage() throws ImageConversionException
Returns theBufferedImage
extracted from the givenImageSource
. Multiple requests will return the same image.- Returns:
- the
BufferedImage
- Throws:
ImageConversionException
- if the givenImageSource
cannot be converted for some reason.
-
getColorModel
public java.awt.image.ColorModel getColorModel() throws ImageConversionException
Returns theColorModel
extracted from the givenImageSource
. Multiple requests will return the same model.- Returns:
- the
ColorModel
- Throws:
ImageConversionException
- if the givenImageSource
cannot be converted for some reason.
-
dispose
public void dispose()
Frees resources used by thisBufferedImageFactory
.
-
abort
public void abort()
Aborts the image production.
-
setSourceRegion
public void setSourceRegion(java.awt.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 factorpYSub
- 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.
-
-