- java.lang.Object
-
- javax.imageio.IIOImage
-
public class IIOImage extends Object
A simple container class to aggregate an image, a set of thumbnail (preview) images, and an object representing metadata associated with the image.The image data may take the form of either a
RenderedImage, or aRaster. Reader methods that return anIIOImagewill always return aBufferedImageusing theRenderedImagereference. Writer methods that accept anIIOImagewill always accept aRenderedImage, and may optionally accept aRaster.Exactly one of
getRenderedImageandgetRasterwill return a non-nullvalue. Subclasses are responsible for ensuring this behavior.- See Also:
ImageReader.readAll(int, ImageReadParam),ImageReader.readAll(java.util.Iterator),ImageWriter.write(javax.imageio.metadata.IIOMetadata, IIOImage, ImageWriteParam),ImageWriter.write(IIOImage),ImageWriter.writeToSequence(IIOImage, ImageWriteParam),ImageWriter.writeInsert(int, IIOImage, ImageWriteParam)
-
-
Field Summary
Fields Modifier and Type Field Description protected RenderedImageimageTheRenderedImagebeing referenced.protected IIOMetadatametadataAnIIOMetadataobject containing metadata associated with the image.protected RasterrasterTheRasterbeing referenced.protected List<? extends BufferedImage>thumbnailsAListofBufferedImagethumbnails, ornull.
-
Constructor Summary
Constructors Constructor Description IIOImage(Raster raster, List<? extends BufferedImage> thumbnails, IIOMetadata metadata)Constructs anIIOImagecontaining aRaster, and thumbnails and metadata associated with it.IIOImage(RenderedImage image, List<? extends BufferedImage> thumbnails, IIOMetadata metadata)Constructs anIIOImagecontaining aRenderedImage, and thumbnails and metadata associated with it.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IIOMetadatagetMetadata()Returns a reference to the currentIIOMetadataobject, ornullis none is set.intgetNumThumbnails()Returns the number of thumbnails stored in thisIIOImage.RastergetRaster()Returns the currently setRaster, ornullif only aRenderedImageis available.RenderedImagegetRenderedImage()Returns the currently setRenderedImage, ornullif only aRasteris available.BufferedImagegetThumbnail(int index)Returns a thumbnail associated with the main image.List<? extends BufferedImage>getThumbnails()Returns the currentListof thumbnailBufferedImages, ornullif none is set.booleanhasRaster()Returnstrueif thisIIOImagestores aRasterrather than aRenderedImage.voidsetMetadata(IIOMetadata metadata)Sets theIIOMetadatato a new object, ornull.voidsetRaster(Raster raster)Sets the currentRaster.voidsetRenderedImage(RenderedImage image)Sets the currentRenderedImage.voidsetThumbnails(List<? extends BufferedImage> thumbnails)Sets the list of thumbnails to a newListofBufferedImages, or tonull.
-
-
-
Field Detail
-
image
protected RenderedImage image
TheRenderedImagebeing referenced.
-
raster
protected Raster raster
TheRasterbeing referenced.
-
thumbnails
protected List<? extends BufferedImage> thumbnails
AListofBufferedImagethumbnails, ornull. Non-BufferedImageobjects must not be stored in thisList.
-
metadata
protected IIOMetadata metadata
AnIIOMetadataobject containing metadata associated with the image.
-
-
Constructor Detail
-
IIOImage
public IIOImage(RenderedImage image, List<? extends BufferedImage> thumbnails, IIOMetadata metadata)
Constructs anIIOImagecontaining aRenderedImage, and thumbnails and metadata associated with it.All parameters are stored by reference.
The
thumbnailsargument must either benullor contain onlyBufferedImageobjects.- Parameters:
image- aRenderedImage.thumbnails- aListofBufferedImages, ornull.metadata- anIIOMetadataobject, ornull.- Throws:
IllegalArgumentException- ifimageisnull.
-
IIOImage
public IIOImage(Raster raster, List<? extends BufferedImage> thumbnails, IIOMetadata metadata)
Constructs anIIOImagecontaining aRaster, and thumbnails and metadata associated with it.All parameters are stored by reference.
- Parameters:
raster- aRaster.thumbnails- aListofBufferedImages, ornull.metadata- anIIOMetadataobject, ornull.- Throws:
IllegalArgumentException- ifrasterisnull.
-
-
Method Detail
-
getRenderedImage
public RenderedImage getRenderedImage()
Returns the currently setRenderedImage, ornullif only aRasteris available.- Returns:
- a
RenderedImage, ornull. - See Also:
setRenderedImage(java.awt.image.RenderedImage)
-
setRenderedImage
public void setRenderedImage(RenderedImage image)
Sets the currentRenderedImage. The value is stored by reference. Any existingRasteris discarded.- Parameters:
image- aRenderedImage.- Throws:
IllegalArgumentException- ifimageisnull.- See Also:
getRenderedImage()
-
hasRaster
public boolean hasRaster()
Returnstrueif thisIIOImagestores aRasterrather than aRenderedImage.- Returns:
trueif aRasteris available.
-
getRaster
public Raster getRaster()
Returns the currently setRaster, ornullif only aRenderedImageis available.- Returns:
- a
Raster, ornull. - See Also:
setRaster(java.awt.image.Raster)
-
setRaster
public void setRaster(Raster raster)
Sets the currentRaster. The value is stored by reference. Any existingRenderedImageis discarded.- Parameters:
raster- aRaster.- Throws:
IllegalArgumentException- ifrasterisnull.- See Also:
getRaster()
-
getNumThumbnails
public int getNumThumbnails()
Returns the number of thumbnails stored in thisIIOImage.- Returns:
- the number of thumbnails, as an
int.
-
getThumbnail
public BufferedImage getThumbnail(int index)
Returns a thumbnail associated with the main image.- Parameters:
index- the index of the desired thumbnail image.- Returns:
- a thumbnail image, as a
BufferedImage. - Throws:
IndexOutOfBoundsException- if the supplied index is negative or larger than the largest valid index.ClassCastException- if a non-BufferedImageobject is encountered in the list of thumbnails at the given index.- See Also:
getThumbnails(),setThumbnails(java.util.List<? extends java.awt.image.BufferedImage>)
-
getThumbnails
public List<? extends BufferedImage> getThumbnails()
Returns the currentListof thumbnailBufferedImages, ornullif none is set. A live reference is returned.- Returns:
- the current
ListofBufferedImagethumbnails, ornull. - See Also:
getThumbnail(int),setThumbnails(java.util.List<? extends java.awt.image.BufferedImage>)
-
setThumbnails
public void setThumbnails(List<? extends BufferedImage> thumbnails)
Sets the list of thumbnails to a newListofBufferedImages, or tonull. The reference to the previousListis discarded.The
thumbnailsargument must either benullor contain onlyBufferedImageobjects.- Parameters:
thumbnails- aListofBufferedImagethumbnails, ornull.- See Also:
getThumbnail(int),getThumbnails()
-
getMetadata
public IIOMetadata getMetadata()
Returns a reference to the currentIIOMetadataobject, ornullis none is set.- Returns:
- an
IIOMetadataobject, ornull. - See Also:
setMetadata(javax.imageio.metadata.IIOMetadata)
-
setMetadata
public void setMetadata(IIOMetadata metadata)
Sets theIIOMetadatato a new object, ornull.- Parameters:
metadata- anIIOMetadataobject, ornull.- See Also:
getMetadata()
-
-