Class IIOImage
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.
- 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 Type | Field | 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
| Constructor | Description |
|---|---|
IIOImage |
Constructs an IIOImage containing a Raster, and thumbnails and metadata associated with it. |
IIOImage |
Constructs an IIOImage containing a RenderedImage, and thumbnails and metadata associated with it. |
Method Summary
| Modifier and Type | Method | 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 |
Returns a thumbnail associated with the main image. |
List<? extends BufferedImage> |
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 |
Sets the IIOMetadata to a new object, or null. |
void |
setRaster |
Sets the current Raster. |
void |
setRenderedImage |
Sets the current RenderedImage. |
void |
setThumbnails |
Sets the list of thumbnails to a new List of BufferedImages, or to null. |
Field Details
image
protected RenderedImage image
RenderedImage being referenced.raster
protected Raster raster
Raster being referenced.thumbnails
protected List<? extends BufferedImage> thumbnails
List of BufferedImage thumbnails, or null. Non-BufferedImage objects must not be stored in this List.metadata
protected IIOMetadata metadata
IIOMetadata object containing metadata associated with the image.Constructor Details
IIOImage
public IIOImage(RenderedImage image, 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.
- Parameters:
-
image- aRenderedImage. -
thumbnails- aListofBufferedImages, ornull. -
metadata- anIIOMetadataobject, ornull. - Throws:
-
IllegalArgumentException- ifimageisnull.
IIOImage
public IIOImage(Raster raster, List<? extends BufferedImage> thumbnails, IIOMetadata metadata)
IIOImage containing a Raster, 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 Details
getRenderedImage
public RenderedImage getRenderedImage()
RenderedImage, or null if only a Raster is available.- Returns:
- a
RenderedImage, ornull. - See Also:
setRenderedImage
public void setRenderedImage(RenderedImage image)
RenderedImage. The value is stored by reference. Any existing Raster is discarded.- Parameters:
-
image- aRenderedImage. - Throws:
-
IllegalArgumentException- ifimageisnull. - See Also:
hasRaster
public boolean hasRaster()
true if this IIOImage stores a Raster rather than a RenderedImage.- Returns:
-
trueif aRasteris available.
getRaster
public Raster getRaster()
Raster, or null if only a RenderedImage is available.- Returns:
- a
Raster, ornull. - See Also:
setRaster
public void setRaster(Raster raster)
Raster. The value is stored by reference. Any existing RenderedImage is discarded.- Parameters:
-
raster- aRaster. - Throws:
-
IllegalArgumentException- ifrasterisnull. - See Also:
getNumThumbnails
public int getNumThumbnails()
IIOImage.- Returns:
- the number of thumbnails, as an
int.
getThumbnail
public BufferedImage getThumbnail(int index)
- 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
public List<? extends BufferedImage> getThumbnails()
List of thumbnail BufferedImages, or null if none is set. A live reference is returned.- Returns:
- the current
ListofBufferedImagethumbnails, ornull. - See Also:
setThumbnails
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.
- Parameters:
-
thumbnails- aListofBufferedImagethumbnails, ornull. - See Also:
getMetadata
public IIOMetadata getMetadata()
IIOMetadata object, or null is none is set.- Returns:
- an
IIOMetadataobject, ornull. - See Also:
setMetadata
public void setMetadata(IIOMetadata metadata)
IIOMetadata to a new object, or null.- Parameters:
-
metadata- anIIOMetadataobject, ornull. - See Also:
© 1993, 2021, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/17/docs/api/java.desktop/javax/imageio/IIOImage.html