public class IIOImage extends Object
The image data may take the form of either a RenderedImage, or a Raster. Reader methods that return an IIOImage will always return a BufferedImage using the RenderedImage reference. Writer methods that accept an IIOImage will always accept a RenderedImage, and may optionally accept a Raster.
Exactly one of getRenderedImage and getRaster will return a non-null value. Subclasses are responsible for ensuring this behavior.
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)
| Modifier and Type | Field and Description |
|---|---|
protected RenderedImage |
image
The
RenderedImage being referenced.
|
protected IIOMetadata |
metadata
An
IIOMetadata object containing metadata associated with the image.
|
protected Raster |
raster
The
Raster being referenced.
|
protected List |
thumbnails
A
List of
BufferedImage thumbnails, or
null.
|
| Constructor and Description |
|---|
IIOImage(Raster
Constructs an
IIOImage containing a
Raster, and thumbnails and metadata associated with it.
|
IIOImage(RenderedImage
Constructs an
IIOImage containing a
RenderedImage, and thumbnails and metadata associated with it.
|
| Modifier and Type | Method and Description |
|---|---|
IIOMetadata |
getMetadata()
Returns a reference to the current
IIOMetadata object, or
null is none is set.
|
int |
getNumThumbnails()
Returns the number of thumbnails stored in this
IIOImage.
|
Raster |
getRaster()
Returns the currently set
Raster, or
null if only a
RenderedImage is available.
|
RenderedImage |
getRenderedImage()
Returns the currently set
RenderedImage, or
null if only a
Raster is available.
|
BufferedImage |
getThumbnail(int index)
Returns a thumbnail associated with the main image.
|
List |
getThumbnails()
Returns the current
List of thumbnail
BufferedImages, or
null if none is set.
|
boolean |
hasRaster()
Returns
true if this
IIOImage stores a
Raster rather than a
RenderedImage.
|
void |
setMetadata(IIOMetadata
Sets the
IIOMetadata to a new object, or
null.
|
void |
setRaster(Raster
Sets the current
Raster.
|
void |
setRenderedImage(RenderedImage
Sets the current
RenderedImage.
|
void |
setThumbnails(List
Sets the list of thumbnails to a new
List of
BufferedImages, or to
null.
|
protected RenderedImageimage
RenderedImage being referenced.
protected Rasterraster
Raster being referenced.
protected List<? extends BufferedImage > thumbnails
List of
BufferedImage thumbnails, or
null. Non-
BufferedImage objects must not be stored in this
List.
protected IIOMetadatametadata
IIOMetadata object containing metadata associated with the image.
public IIOImage(RenderedImageimage, List <? extends BufferedImage > thumbnails, IIOMetadata metadata)
IIOImage containing a
RenderedImage, and thumbnails and metadata associated with it.
All parameters are stored by reference.
The thumbnails argument must either be null or contain only BufferedImage objects.
image - a
RenderedImage.
thumbnails - a
List of
BufferedImages, or
null.
metadata - an
IIOMetadata object, or
null.
IllegalArgumentException - if
image is
null.
public IIOImage(Rasterraster, List <? extends BufferedImage > thumbnails, IIOMetadata metadata)
IIOImage containing a
Raster, and thumbnails and metadata associated with it.
All parameters are stored by reference.
raster - a
Raster.
thumbnails - a
List of
BufferedImages, or
null.
metadata - an
IIOMetadata object, or
null.
IllegalArgumentException - if
raster is
null.
public RenderedImagegetRenderedImage()
RenderedImage, or
null if only a
Raster is available.
RenderedImage, or
null.
setRenderedImage(java.awt.image.RenderedImage)
public void setRenderedImage(RenderedImageimage)
RenderedImage. The value is stored by reference. Any existing
Raster is discarded.
image - a
RenderedImage.
IllegalArgumentException - if
image is
null.
getRenderedImage()
public boolean hasRaster()
true if this
IIOImage stores a
Raster rather than a
RenderedImage.
true if a
Raster is available.
public RastergetRaster()
Raster, or
null if only a
RenderedImage is available.
Raster, or
null.
setRaster(java.awt.image.Raster)
public void setRaster(Rasterraster)
Raster. The value is stored by reference. Any existing
RenderedImage is discarded.
raster - a
Raster.
IllegalArgumentException - if
raster is
null.
getRaster()
public int getNumThumbnails()
IIOImage.
int.
public BufferedImagegetThumbnail(int index)
index - the index of the desired thumbnail image.
BufferedImage.
IndexOutOfBoundsException - if the supplied index is negative or larger than the largest valid index.
ClassCastException - if a non-
BufferedImage object is encountered in the list of thumbnails at the given index.
getThumbnails(),
setThumbnails(java.util.List<? extends java.awt.image.BufferedImage>)
public List<? extends BufferedImage > getThumbnails()
List of thumbnail
BufferedImages, or
null if none is set. A live reference is returned.
List of
BufferedImage thumbnails, or
null.
getThumbnail(int),
setThumbnails(java.util.List<? extends java.awt.image.BufferedImage>)
public void setThumbnails(List<? extends BufferedImage > thumbnails)
List of
BufferedImages, or to
null. The reference to the previous
List is discarded.
The thumbnails argument must either be null or contain only BufferedImage objects.
thumbnails - a
List of
BufferedImage thumbnails, or
null.
getThumbnail(int),
getThumbnails()
public IIOMetadatagetMetadata()
IIOMetadata object, or
null is none is set.
IIOMetadata object, or
null.
setMetadata(javax.imageio.metadata.IIOMetadata)
public void setMetadata(IIOMetadatametadata)
IIOMetadata to a new object, or
null.
metadata - an
IIOMetadata object, or
null.
getMetadata()