Package com.twelvemonkeys.image
Class BufferedImageFactory
java.lang.Object
com.twelvemonkeys.image.BufferedImageFactory
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
Nested ClassesModifier and TypeClassDescriptionstatic interfaceThis interface allows clients of aBufferedImageFactoryto receive notifications of decoding progress. -
Constructor Summary
ConstructorsConstructorDescriptionBufferedImageFactory(Image pSource) Creates aBufferedImageFactory.BufferedImageFactory(ImageProducer pSource) Creates aBufferedImageFactory. -
Method Summary
Modifier and TypeMethodDescriptionvoidabort()Aborts the image production.voidAdds a progress listener to this factory.voiddispose()Frees resources used by thisBufferedImageFactory.Returns theBufferedImageextracted from the givenImageSource.Returns theColorModelextracted from the givenImageSource.voidRemoves all progress listeners from this factory.voidRemoves a progress listener from this factory.voidsetSourceRegion(Rectangle pRegion) Sets the source region (AOI) for the new image.voidsetSourceSubsampling(int pXSub, int pYSub) Sets the source subsampling for the new image.
-
Constructor Details
-
BufferedImageFactory
Creates aBufferedImageFactory.- Parameters:
pSource- the source image- Throws:
IllegalArgumentException- ifpSource == null
-
BufferedImageFactory
Creates aBufferedImageFactory.- Parameters:
pSource- the source image producer- Throws:
IllegalArgumentException- ifpSource == null
-
-
Method Details
-
getBufferedImage
Returns theBufferedImageextracted from the givenImageSource. Multiple requests will return the same image.- Returns:
- the
BufferedImage - Throws:
ImageConversionException- if the givenImageSourcecannot be converted for some reason.
-
getColorModel
Returns theColorModelextracted from the givenImageSource. Multiple requests will return the same model.- Returns:
- the
ColorModel - Throws:
ImageConversionException- if the givenImageSourcecannot be converted for some reason.
-
dispose
public void dispose()Frees resources used by thisBufferedImageFactory. -
abort
public void abort()Aborts the image production. -
setSourceRegion
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
Adds a progress listener to this factory.- Parameters:
pListener- the progress listener
-
removeProgressListener
Removes a progress listener from this factory.- Parameters:
pListener- the progress listener
-
removeAllProgressListeners
public void removeAllProgressListeners()Removes all progress listeners from this factory.
-