FileDocCategorySizeDatePackage
IIOImage.javaAPI DocJava SE 5 API9466Fri Aug 26 14:57:30 BST 2005javax.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 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.

see
ImageReader#readAll(int, ImageReadParam)
see
ImageReader#readAll(java.util.Iterator)
see
ImageWriter#write(javax.imageio.metadata.IIOMetadata, IIOImage, ImageWriteParam)
see
ImageWriter#write(IIOImage)
see
ImageWriter#writeToSequence(IIOImage, ImageWriteParam)
see
ImageWriter#writeInsert(int, IIOImage, ImageWriteParam)
version
0.5

Fields Summary
protected RenderedImage
image
The RenderedImage being referenced.
protected Raster
raster
The Raster being referenced.
protected List
thumbnails
A List of BufferedImage thumbnails, or null. Non-BufferedImage objects must not be stored in this List.
protected IIOMetadata
metadata
An IIOMetadata object containing metadata associated with the image.
Constructors Summary
public IIOImage(RenderedImage image, List thumbnails, IIOMetadata metadata)
Constructs an 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.

param
image a RenderedImage.
param
thumbnails a List of BufferedImages, or null.
param
metadata an IIOMetadata object, or null.
exception
IllegalArgumentException if image is null.


                                                                   
      
                       
                      
        if (image == null) {
            throw new IllegalArgumentException("image == null!");
        }
        this.image = image;
        this.raster = null;
        this.thumbnails = thumbnails;
        this.metadata = metadata;
    
public IIOImage(Raster raster, List thumbnails, IIOMetadata metadata)
Constructs an IIOImage containing a Raster, and thumbnails and metadata associated with it.

All parameters are stored by reference.

param
raster a Raster.
param
thumbnails a List of BufferedImages, or null.
param
metadata an IIOMetadata object, or null.
exception
IllegalArgumentException if raster is null.

        if (raster == null) {
            throw new IllegalArgumentException("raster == null!");
        }
        this.raster = raster;
        this.image = null;
        this.thumbnails = thumbnails;
        this.metadata = metadata;
    
Methods Summary
public javax.imageio.metadata.IIOMetadatagetMetadata()
Returns a reference to the current IIOMetadata object, or null is none is set.

return
an IIOMetadata object, or null.
see
#setMetadata

        return metadata;
    
public intgetNumThumbnails()
Returns the number of thumbnails stored in this IIOImage.

return
the number of thumbnails, as an int.

        return thumbnails == null ? 0 : thumbnails.size();
    
public java.awt.image.RastergetRaster()
Returns the currently set Raster, or null if only a RenderedImage is available.

return
a Raster, or null.
see
#setRaster

        synchronized(this) {
            return raster;
        }
    
public java.awt.image.RenderedImagegetRenderedImage()
Returns the currently set RenderedImage, or null if only a Raster is available.

return
a RenderedImage, or null.
see
#setRenderedImage

        synchronized(this) {
            return image;
        }
    
public java.awt.image.BufferedImagegetThumbnail(int index)
Returns a thumbnail associated with the main image.

param
index the index of the desired thumbnail image.
return
a thumbnail image, as a BufferedImage.
exception
IndexOutOfBoundsException if the supplied index is negative or larger than the largest valid index.
exception
ClassCastException if a non-BufferedImage object is encountered in the list of thumbnails at the given index.
see
#getThumbnails
see
#setThumbnails

        if (thumbnails == null) {
            throw new IndexOutOfBoundsException("No thumbnails available!");
        }
        return (BufferedImage)thumbnails.get(index);
    
public java.util.ListgetThumbnails()
Returns the current List of thumbnail BufferedImages, or null if none is set. A live reference is returned.

return
the current List of BufferedImage thumbnails, or null.
see
#getThumbnail(int)
see
#setThumbnails

        return thumbnails;
    
public booleanhasRaster()
Returns true if this IIOImage stores a Raster rather than a RenderedImage.

return
true if a Raster is available.

        synchronized(this) {
            return (raster != null);
        }
    
public voidsetMetadata(javax.imageio.metadata.IIOMetadata metadata)
Sets the IIOMetadata to a new object, or null.

param
metadata an IIOMetadata object, or null.
see
#getMetadata

        this.metadata = metadata;
    
public voidsetRaster(java.awt.image.Raster raster)
Sets the current Raster. The value is stored by reference. Any existing RenderedImage is discarded.

param
raster a Raster.
exception
IllegalArgumentException if raster is null.
see
#getRaster

        synchronized(this) {
            if (raster == null) {
                throw new IllegalArgumentException("raster == null!");
            }
            this.raster = raster;
            this.image = null;
        }
    
public voidsetRenderedImage(java.awt.image.RenderedImage image)
Sets the current RenderedImage. The value is stored by reference. Any existing Raster is discarded.

param
image a RenderedImage.
exception
IllegalArgumentException if image is null.
see
#getRenderedImage

        synchronized(this) {
            if (image == null) {
                throw new IllegalArgumentException("image == null!");
            }
            this.image = image;
            this.raster = null;
        }
    
public voidsetThumbnails(java.util.List thumbnails)
Sets the list of thumbnails to a new 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.

param
thumbnails a List of BufferedImage thumbnails, or null.
see
#getThumbnail(int)
see
#getThumbnails

        this.thumbnails = thumbnails;