Class IIOImage

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 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:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected RenderedImage
    The RenderedImage being referenced.
    protected IIOMetadata
    An IIOMetadata object containing metadata associated with the image.
    protected Raster
    The Raster being referenced.
    protected List<? extends BufferedImage>
    A List of BufferedImage thumbnails, or null.
  • Constructor Summary

    Constructors
    Constructor
    Description
    IIOImage(Raster raster, List<? extends BufferedImage> thumbnails, IIOMetadata metadata)
    Constructs an IIOImage containing a Raster, and thumbnails and metadata associated with it.
    IIOImage(RenderedImage image, List<? extends BufferedImage> thumbnails, IIOMetadata metadata)
    Constructs an IIOImage containing a RenderedImage, and thumbnails and metadata associated with it.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns a reference to the current IIOMetadata object, or null is none is set.
    int
    Returns the number of thumbnails stored in this IIOImage.
    Returns the currently set Raster, or null if only a RenderedImage is available.
    Returns the currently set RenderedImage, or null if only a Raster is available.
    getThumbnail(int index)
    Returns a thumbnail associated with the main image.
    List<? extends BufferedImage>
    Returns the current List of thumbnail BufferedImages, or null if none is set.
    boolean
    Returns true if this IIOImage stores a Raster rather than a RenderedImage.
    void
    Sets the IIOMetadata to a new object, or null.
    void
    setRaster(Raster raster)
    Sets the current Raster.
    void
    Sets the current RenderedImage.
    void
    setThumbnails(List<? extends BufferedImage> thumbnails)
    Sets the list of thumbnails to a new List of BufferedImages, or to null.

    Methods declared in class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    Modifier and Type
    Method
    Description
    protected Object
    Answers a new instance of the same class as the receiver, whose slots have been filled in with the values in the slots of the receiver.
    boolean
    Compares the argument to the receiver, and answers true if they represent the same object using a class specific comparison.
    protected void
    Deprecated, for removal: This API element is subject to removal in a future version.
    May cause performance issues, deadlocks and hangs.
    final Class<? extends Object>
    Answers the unique instance of java.lang.Class which represents the class of the receiver.
    int
    Answers an integer hash code for the receiver.
    final void
    Causes one thread which is waiting on the receiver to be made ready to run.
    final void
    Causes all threads which are waiting on the receiver to be made ready to run.
    Answers a string containing a concise, human-readable description of the receiver.
    final void
    Causes the thread which sent this message to be made not ready to run pending some change in the receiver (as indicated by notify or notifyAll).
    final void
    wait(long time)
    Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated by notify or notifyAll) or the expiration of the timeout.
    final void
    wait(long time, int frac)
    Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated by notify or notifyAll) or the expiration of the timeout.
  • Field Details

    • image

      protected RenderedImage image
      The RenderedImage being referenced.
    • raster

      protected Raster raster
      The Raster being referenced.
    • thumbnails

      protected List<? extends BufferedImage> thumbnails
      A List of BufferedImage thumbnails, or null. Non-BufferedImage objects must not be stored in this List.
    • metadata

      protected IIOMetadata metadata
      An IIOMetadata object containing metadata associated with the image.
  • Constructor Details

    • IIOImage

      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 - a RenderedImage.
      thumbnails - a List of BufferedImages, or null.
      metadata - an IIOMetadata object, or null.
      Throws:
      IllegalArgumentException - if image is null.
    • IIOImage

      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 - a Raster.
      thumbnails - a List of BufferedImages, or null.
      metadata - an IIOMetadata object, or null.
      Throws:
      IllegalArgumentException - if raster is null.
  • Method Details

    • getRenderedImage

      public RenderedImage getRenderedImage()
      Returns the currently set RenderedImage, or null if only a Raster is available.
      Returns:
      a RenderedImage, or null.
      See Also:
    • setRenderedImage

      public void setRenderedImage(RenderedImage image)
      Sets the current RenderedImage. The value is stored by reference. Any existing Raster is discarded.
      Parameters:
      image - a RenderedImage.
      Throws:
      IllegalArgumentException - if image is null.
      See Also:
    • hasRaster

      public boolean hasRaster()
      Returns true if this IIOImage stores a Raster rather than a RenderedImage.
      Returns:
      true if a Raster is available.
    • getRaster

      public Raster getRaster()
      Returns the currently set Raster, or null if only a RenderedImage is available.
      Returns:
      a Raster, or null.
      See Also:
    • setRaster

      public void setRaster(Raster raster)
      Sets the current Raster. The value is stored by reference. Any existing RenderedImage is discarded.
      Parameters:
      raster - a Raster.
      Throws:
      IllegalArgumentException - if raster is null.
      See Also:
    • getNumThumbnails

      public int getNumThumbnails()
      Returns the number of thumbnails stored in this IIOImage.
      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-BufferedImage object is encountered in the list of thumbnails at the given index.
      See Also:
    • getThumbnails

      public List<? extends BufferedImage> getThumbnails()
      Returns the current List of thumbnail BufferedImages, or null if none is set. A live reference is returned.
      Returns:
      the current List of BufferedImage thumbnails, or null.
      See Also:
    • setThumbnails

      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 - a List of BufferedImage thumbnails, or null.
      See Also:
    • getMetadata

      public IIOMetadata getMetadata()
      Returns a reference to the current IIOMetadata object, or null is none is set.
      Returns:
      an IIOMetadata object, or null.
      See Also:
    • setMetadata

      public void setMetadata(IIOMetadata metadata)
      Sets the IIOMetadata to a new object, or null.
      Parameters:
      metadata - an IIOMetadata object, or null.
      See Also: