APIdia Launch Partner
Top Description Fields Constructors Methods
javax.imageio

public Class IIOImage

extends Object
Class Inheritance
Imports
java.awt.image.BufferedImage, .Raster, .RenderedImage, java.util.List, javax.imageio.metadata.IIOMetadata

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 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

Modifier and TypeField 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<? extends BufferedImage>
thumbnails

A List of BufferedImage thumbnails, or null.

Constructor Summary

AccessConstructor and Description
public
IIOImage(RenderedImage
a RenderedImage.
image
,
List<? extends BufferedImage>
a List of BufferedImages, or null.
thumbnails
,
IIOMetadata
an IIOMetadata object, or null.
metadata
)

Constructs an IIOImage containing a RenderedImage, and thumbnails and metadata associated with it.

public
IIOImage(Raster
a Raster.
raster
,
List<? extends BufferedImage>
a List of BufferedImages, or null.
thumbnails
,
IIOMetadata
an IIOMetadata object, or null.
metadata
)

Constructs an IIOImage containing a Raster, and thumbnails and metadata associated with it.

Method Summary

Modifier and TypeMethod and Description
public IIOMetadata

Returns:

an IIOMetadata object, or null.
getMetadata
()

Returns a reference to the current IIOMetadata object, or null is none is set.

public int

Returns:

the number of thumbnails, as an int.
getNumThumbnails
()

Returns the number of thumbnails stored in this IIOImage.

public Raster

Returns:

a Raster, or null.
getRaster
()

Returns the currently set Raster, or null if only a RenderedImage is available.

public RenderedImage

Returns:

a RenderedImage, or null.
getRenderedImage
()

Returns the currently set RenderedImage, or null if only a Raster is available.

public BufferedImage

Returns:

a thumbnail image, as a BufferedImage.
getThumbnail
(int
the index of the desired thumbnail image.
index
)

Returns a thumbnail associated with the main image.

public List<? extends BufferedImage>

Returns:

the current List of BufferedImage thumbnails, or null.
getThumbnails
()

Returns the current List of thumbnail BufferedImages, or null if none is set.

public boolean

Returns:

true if a Raster is available.
hasRaster
()

Returns true if this IIOImage stores a Raster rather than a RenderedImage.

public void
setMetadata(IIOMetadata
an IIOMetadata object, or null.
metadata
)

Sets the IIOMetadata to a new object, or null.

public void
setRaster(Raster
a Raster.
raster
)

Sets the current Raster.

public void
setRenderedImage(RenderedImage
a RenderedImage.
image
)

Sets the current RenderedImage.

public void
setThumbnails(List<? extends BufferedImage>
a List of BufferedImage thumbnails, or null.
thumbnails
)

Sets the list of thumbnails to a new List of BufferedImages, or to null.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

imageback to summary
protected RenderedImage image

The RenderedImage being referenced.

metadataback to summary
protected IIOMetadata metadata

An IIOMetadata object containing metadata associated with the image.

rasterback to summary
protected Raster raster

The Raster being referenced.

thumbnailsback to summary
protected List<? extends BufferedImage> thumbnails

A List of BufferedImage thumbnails, or null. Non-BufferedImage objects must not be stored in this List.

Constructor Detail

IIOImageback to summary
public IIOImage(RenderedImage image, List<? extends BufferedImage> 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.

Parameters
image:RenderedImage

a RenderedImage.

thumbnails:List<? extends BufferedImage>

a List of BufferedImages, or null.

metadata:IIOMetadata

an IIOMetadata object, or null.

Exceptions
IllegalArgumentException:
if image is null.
IIOImageback to summary
public IIOImage(Raster raster, List<? extends BufferedImage> thumbnails, IIOMetadata metadata)

Constructs an IIOImage containing a Raster, and thumbnails and metadata associated with it.

All parameters are stored by reference.

Parameters
raster:Raster

a Raster.

thumbnails:List<? extends BufferedImage>

a List of BufferedImages, or null.

metadata:IIOMetadata

an IIOMetadata object, or null.

Exceptions
IllegalArgumentException:
if raster is null.

Method Detail

getMetadataback to summary
public IIOMetadata getMetadata()

Returns a reference to the current IIOMetadata object, or null is none is set.

Returns:IIOMetadata

an IIOMetadata object, or null.

See Also
setMetadata
getNumThumbnailsback to summary
public int getNumThumbnails()

Returns the number of thumbnails stored in this IIOImage.

Returns:int

the number of thumbnails, as an int.

getRasterback to summary
public Raster getRaster()

Returns the currently set Raster, or null if only a RenderedImage is available.

Returns:Raster

a Raster, or null.

See Also
setRaster
getRenderedImageback to summary
public RenderedImage getRenderedImage()

Returns the currently set RenderedImage, or null if only a Raster is available.

Returns:RenderedImage

a RenderedImage, or null.

See Also
setRenderedImage
getThumbnailback to summary
public BufferedImage getThumbnail(int index)

Returns a thumbnail associated with the main image.

Parameters
index:int

the index of the desired thumbnail image.

Returns:BufferedImage

a thumbnail image, as a BufferedImage.

Exceptions
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.
See Also
getThumbnails, setThumbnails
getThumbnailsback to summary
public List<? extends BufferedImage> getThumbnails()

Returns the current List of thumbnail BufferedImages, or null if none is set. A live reference is returned.

Returns:List<? extends BufferedImage>

the current List of BufferedImage thumbnails, or null.

See Also
getThumbnail(int), setThumbnails
hasRasterback to summary
public boolean hasRaster()

Returns true if this IIOImage stores a Raster rather than a RenderedImage.

Returns:boolean

true if a Raster is available.

setMetadataback to summary
public void setMetadata(IIOMetadata metadata)

Sets the IIOMetadata to a new object, or null.

Parameters
metadata:IIOMetadata

an IIOMetadata object, or null.

See Also
getMetadata
setRasterback to summary
public void setRaster(Raster raster)

Sets the current Raster. The value is stored by reference. Any existing RenderedImage is discarded.

Parameters
raster:Raster

a Raster.

Exceptions
IllegalArgumentException:
if raster is null.
See Also
getRaster
setRenderedImageback to summary
public void setRenderedImage(RenderedImage image)

Sets the current RenderedImage. The value is stored by reference. Any existing Raster is discarded.

Parameters
image:RenderedImage

a RenderedImage.

Exceptions
IllegalArgumentException:
if image is null.
See Also
getRenderedImage
setThumbnailsback to summary
public void setThumbnails(List<? extends BufferedImage> 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.

Parameters
thumbnails:List<? extends BufferedImage>

a List of BufferedImage thumbnails, or null.

See Also
getThumbnail(int), getThumbnails