An abstract superclass for encoding and writing images. This class must be subclassed by classes that write out images in the context of the Java Image I/O framework.

ImageWriter objects are normally instantiated by the service provider class for the specific format. Service provider classes are registered with the IIORegistry, which uses them for format recognition and presentation of available format readers and writers.

Requests that any current write operation be aborted. The contents of the output following the abort will be undefined.

Writers should call clearAbortRequest at the beginning of each write operation, and poll the value of abortRequested regularly during the write.

Adds an IIOWriteProgressListener to the list of registered progress listeners. If listener is null, no exception will be thrown and no action will be taken.
Parameters
listeneran IIOWriteProgressListener to be registered.
Adds an IIOWriteWarningListener to the list of registered warning listeners. If listener is null, no exception will be thrown and no action will be taken. Messages sent to the given listener will be localized, if possible, to match the current Locale. If no Locale has been set, warning messages may be localized as the writer sees fit.
Parameters
listeneran IIOWriteWarningListener to be registered.
Returns true if the writer supports the insertion of a new, empty image at the given index. The pixel values of the image are undefined, and may be specified in pieces using the replacePixels methods. Existing images with indices greater than or equal to the insertion index will have their indices increased by 1. A value for imageIndex of -1 may be used to signify an index one larger than the current largest index.

A writer that does not support insertion of empty images may return false without performing bounds checking on the index.

The default implementation throws an IllegalStateException if the output is null, and otherwise returns false without checking the value of imageIndex.

Parameters
imageIndexthe index at which the image is to be inserted.
Return
true if an empty image may be inserted at the given index.
Throws
IllegalStateExceptionif the output has not been set.
IndexOutOfBoundsExceptionif the writer supports empty image insertion in general, but imageIndex is less than -1 or greater than the largest available index.
IOExceptionif an I/O error occurs during the query.
Returns true if the writer supports the insertion of a new image at the given index. Existing images with indices greater than or equal to the insertion index will have their indices increased by 1. A value for imageIndex of -1 may be used to signify an index one larger than the current largest index.

A writer that does not support any image insertion may return false without performing bounds checking on the index.

The default implementation throws an IllegalStateException if the output is null, and otherwise returns false withour checking the value of imageIndex.

Parameters
imageIndexthe index at which the image is to be inserted.
Return
true if an image may be inserted at the given index.
Throws
IllegalStateExceptionif the output has not been set.
IndexOutOfBoundsExceptionif the writer supports image insertion in general, but imageIndex is less than -1 or greater than the largest available index.
IOExceptionif an I/O error occurs during the query.
Returns true if the writer supports the removal of an existing image at the given index. Existing images with indices greater than the insertion index will have their indices decreased by 1.

A writer that does not support any image removal may return false without performing bounds checking on the index.

The default implementation throws an IllegalStateException if the output is null, and otherwise returns false without checking the value of imageIndex.

Parameters
imageIndexthe index of the image to be removed.
Return
true if it is possible to remove the given image.
Throws
IllegalStateExceptionif the output has not been set.
IndexOutOfBoundsExceptionif the writer supports image removal in general, but imageIndex is less than 0 or greater than the largest available index.
IOExceptionif an I/O error occurs during the query.
Returns true if it is possible to replace the image metadata associated with an existing image with index imageIndex. If this method returns false, a call to replaceImageMetadata(imageIndex) will throw an UnsupportedOperationException.

A writer that does not support any image metadata replacement may return false without performing bounds checking on the index.

The default implementation throws an IllegalStateException if the output is null, and otherwise returns false without checking the value of imageIndex.

Parameters
imageIndexthe index of the image whose metadata is to be replaced.
Return
true if the image metadata of the given image can be replaced.
Throws
IllegalStateExceptionif the output has not been set.
IndexOutOfBoundsExceptionif the writer supports image metadata replacement in general, but imageIndex is less than 0 or greater than the largest available index.
IOExceptionif an I/O error occurs during the query.
Returns true if the writer allows pixels of the given image to be replaced using the replacePixels methods.

A writer that does not support any pixel replacement may return false without performing bounds checking on the index.

The default implementation throws an IllegalStateException if the output is null, and otherwise returns false without checking the value of imageIndex.

Parameters
imageIndexthe index of the image whose pixels are to be replaced.
Return
true if the pixels of the given image can be replaced.
Throws
IllegalStateExceptionif the output has not been set.
IndexOutOfBoundsExceptionif the writer supports pixel replacement in general, but imageIndex is less than 0 or greater than the largest available index.
IOExceptionif an I/O error occurs during the query.
Returns true if it is possible to replace the stream metadata already present in the output.

The default implementation throws an IllegalStateException if the output is null, and otherwise returns false.

Return
true if replacement of stream metadata is allowed.
Throws
IllegalStateExceptionif the output has not been set.
IOExceptionif an I/O error occurs during the query.
Returns true if the writer supports the writing of a complete image stream consisting of a single image with undefined pixel values and associated metadata and thumbnails to the output. The pixel values may be defined by future calls to the replacePixels methods. If the output is an ImageOutputStream, its existing contents prior to the current seek position are not affected, and need not be readable or writable.

The default implementation throws an IllegalStateException if the output is null, and otherwise returns false.

Return
true if the writing of complete image stream with contents to be defined later is supported.
Throws
IllegalStateExceptionif the output has not been set.
IOExceptionif an I/O error occurs during the query.
Returns true if the methods that take an IIOImage parameter are capable of dealing with a Raster (as opposed to RenderedImage) source image. If this method returns false, then those methods will throw an UnsupportedOperationException if supplied with an IIOImage containing a Raster.

The default implementation returns false.

Return
true if Raster sources are supported.
Returns true if the writer is able to append an image to an image stream that already contains header information and possibly prior images.

If canWriteSequence returns false, writeToSequence and endWriteSequence will throw an UnsupportedOperationException.

The default implementation returns false.

Return
true if images may be appended sequentially.
Returns an IIOMetadata object that may be used for encoding and optionally modified using its document interfaces or other interfaces specific to the writer plug-in that will be used for encoding.

An optional ImageWriteParam may be supplied for cases where it may affect the structure of the image metadata.

If the supplied ImageWriteParam contains optional setting values not understood by this writer or transcoder, they will be ignored.

Parameters
inDataan IIOMetadata object representing image metadata, used to initialize the state of the returned object.
imageTypean ImageTypeSpecifier indicating the layout and color information of the image with which the metadata will be associated.
paraman ImageWriteParam that will be used to encode the image, or null.
Return
an IIOMetadata object, or null if the plug-in does not provide metadata encoding capabilities.
Throws
IllegalArgumentExceptionif either of inData or imageType is null.
Returns an IIOMetadata object that may be used for encoding and optionally modified using its document interfaces or other interfaces specific to the writer plug-in that will be used for encoding.

An optional ImageWriteParam may be supplied for cases where it may affect the structure of the stream metadata.

If the supplied ImageWriteParam contains optional setting values not understood by this writer or transcoder, they will be ignored.

Parameters
inDataan IIOMetadata object representing stream metadata, used to initialize the state of the returned object.
paraman ImageWriteParam that will be used to encode the image, or null.
Return
an IIOMetadata object, or null if the plug-in does not provide metadata encoding capabilities.
Throws
IllegalArgumentExceptionif inData is null.
Allows any resources held by this object to be released. The result of calling any other method (other than finalize) subsequent to a call to this method is undefined.

It is important for applications to call this method when they know they will no longer be using this ImageWriter. Otherwise, the writer may continue to hold on to resources indefinitely.

The default implementation of this method in the superclass does nothing. Subclass implementations should ensure that all resources, especially native resources, are released.

Completes the insertion of a new image that was begun with a prior call to prepareInsertEmpty.

The default implementation throws an IllegalStateException if the output is null, and otherwise throws an UnsupportedOperationException.

Throws
IllegalStateExceptionif the output has not been set.
UnsupportedOperationExceptionif canInsertEmpty(imageIndex) returns false.
IllegalStateExceptionif a previous call to prepareInsertEmpty without a corresponding call to endInsertEmpty has not been made.
IllegalStateExceptionif a previous call to prepareWriteEmpty without a corresponding call to endWriteEmpty has been made.
IllegalStateExceptionif a call to prepareReplacePixels has been made without a matching call to endReplacePixels.
IOExceptionif an I/O error occurs during writing.
Terminates a sequence of calls to replacePixels.

If canReplacePixels returns false, and UnsupportedOperationException will be thrown.

The default implementation throws an IllegalStateException if the output is null, and otherwise throws an UnsupportedOperationException.

Throws
IllegalStateExceptionif the output has not been set.
UnsupportedOperationExceptionif canReplacePixels(imageIndex) returns false.
IllegalStateExceptionif there is no previous call to prepareReplacePixels without a matching call to endReplacePixels.
IOExceptionif an I/O error occurs during writing.
Completes the writing of a new image that was begun with a prior call to prepareWriteEmpty.

If canWriteEmpty() returns false, an UnsupportedOperationException will be thrown.

The default implementation throws an IllegalStateException if the output is null, and otherwise throws an UnsupportedOperationException.

Throws
IllegalStateExceptionif the output has not been set.
UnsupportedOperationExceptionif canWriteEmpty(imageIndex) returns false.
IllegalStateExceptionif a previous call to prepareWriteEmpty without a corresponding call to endWriteEmpty has not been made.
IllegalStateExceptionif a previous call to prepareInsertEmpty without a corresponding call to endInsertEmpty has been made.
IllegalStateExceptionif a call to prepareReiplacePixels has been made without a matching call to endReplacePixels.
IOExceptionif an I/O error occurs during writing.
Completes the writing of a sequence of images begun with prepareWriteSequence. Any stream metadata that should come at the end of the sequence of images is written out, and any header information at the beginning of the sequence is patched up if necessary. If the output is an ImageOutputStream, data through the stream metadata at the end of the sequence are flushed and need not be readable or writable.

If canWriteSequence returns false, this method will throw an UnsupportedOperationException.

The default implementation throws an IllegalStateException if the output is null, and otherwise throws an UnsupportedOperationException.

Throws
IllegalStateExceptionif the output has not been set, or prepareWriteSequence has not been called.
UnsupportedOperationExceptionif canWriteSequence returns false.
IOExceptionif an error occurs during writing.
Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

The equals method for class Object implements the most discriminating possible equivalence relation on objects; that is, for any non-null reference values x and y, this method returns true if and only if x and y refer to the same object (x == y has the value true).

Note that it is generally necessary to override the hashCode method whenever this method is overridden, so as to maintain the general contract for the hashCode method, which states that equal objects must have equal hash codes.

Parameters
objthe reference object with which to compare.
Return
true if this object is the same as the obj argument; false otherwise.
Returns an array of Locales that may be used to localize warning listeners and compression settings. A return value of null indicates that localization is not supported.

The default implementation returns a clone of the availableLocales instance variable if it is non-null, or else returns null.

Return
an array of Locales that may be used as arguments to setLocale, or null.
Returns the runtime class of an object. That Class object is the object that is locked by static synchronized methods of the represented class.
Return
The java.lang.Class object that represents the runtime class of the object. The result is of type {@code Class} where X is the erasure of the static type of the expression on which getClass is called.
Returns an IIOMetadata object containing default values for encoding an image of the given type. The contents of the object may be manipulated using either the XML tree structure returned by the IIOMetadata.getAsTree method, an IIOMetadataController object, or via plug-in specific interfaces, and the resulting data supplied to one of the write methods that take a stream metadata parameter.

An optional ImageWriteParam may be supplied for cases where it may affect the structure of the image metadata.

If the supplied ImageWriteParam contains optional setting values not supported by this writer (e.g. progressive encoding or any format-specific settings), they will be ignored.

Parameters
imageTypean ImageTypeSpecifier indicating the format of the image to be written later.
paraman ImageWriteParam that will be used to encode the image, or null.
Return
an IIOMetadata object.
Returns an IIOMetadata object containing default values for encoding a stream of images. The contents of the object may be manipulated using either the XML tree structure returned by the IIOMetadata.getAsTree method, an IIOMetadataController object, or via plug-in specific interfaces, and the resulting data supplied to one of the write methods that take a stream metadata parameter.

An optional ImageWriteParam may be supplied for cases where it may affect the structure of the stream metadata.

If the supplied ImageWriteParam contains optional setting values not supported by this writer (e.g. progressive encoding or any format-specific settings), they will be ignored.

Writers that do not make use of stream metadata (e.g., writers for single-image formats) should return null.

Parameters
paraman ImageWriteParam that will be used to encode the image, or null.
Return
an IIOMetadata object.
Returns a new ImageWriteParam object of the appropriate type for this file format containing default values, that is, those values that would be used if no ImageWriteParam object were specified. This is useful as a starting point for tweaking just a few parameters and otherwise leaving the default settings alone.

The default implementation constructs and returns a new ImageWriteParam object that does not allow tiling, progressive encoding, or compression, and that will be localized for the current Locale (i.e., what you would get by calling new ImageWriteParam(getLocale()).

Individual plug-ins may return an instance of ImageWriteParam with additional optional features enabled, or they may return an instance of a plug-in specific subclass of ImageWriteParam.

Return
a new ImageWriteParam object containing default values.
Returns the currently set Locale, or null if none has been set.

The default implementation returns the value of the locale instance variable.

Return
the current Locale, or null.
See Also
Returns the number of thumbnails suported by the format being written, given the image type and any additional write parameters and metadata objects that will be used during encoding. A return value of -1 indicates that insufficient information is available.

An ImageWriteParam may optionally be supplied for cases where it may affect thumbnail handling.

If the supplied ImageWriteParam contains optional setting values not supported by this writer (e.g. progressive encoding or any format-specific settings), they will be ignored.

The default implementation returns 0.

Parameters
imageTypean ImageTypeSpecifier indicating the type of image to be written, or null.
paramthe ImageWriteParam that will be used for writing, or null.
streamMetadataan IIOMetadata object that will be used for writing, or null.
imageMetadataan IIOMetadata object that will be used for writing, or null.
Return
the number of thumbnails that may be written given the supplied parameters, or -1 if insufficient information is available.
Returns the ImageWriterSpi object that created this ImageWriter, or null if this object was not created through the IIORegistry.

The default implementation returns the value of the originatingProvider instance variable.

Return
an ImageWriterSpi, or null.
Returns the ImageOutputStream or other Object set by the most recent call to the setOutput method. If no destination has been set, null is returned.

The default implementation returns the value of the output instance variable.

Return
the Object that was specified using setOutput, or null.
See Also
Returns an array of Dimensions indicating the legal size ranges for thumbnail images as they will be encoded in the output file or stream. This information is merely advisory; the writer will resize any supplied thumbnails as necessary.

The information is returned as a set of pairs; the first element of a pair contains an (inclusive) minimum width and height, and the second element contains an (inclusive) maximum width and height. Together, each pair defines a valid range of sizes. To specify a fixed size, the same width and height will appear for both elements. A return value of null indicates that the size is arbitrary or unknown.

An ImageWriteParam may optionally be supplied for cases where it may affect thumbnail handling.

If the supplied ImageWriteParam contains optional setting values not supported by this writer (e.g. progressive encoding or any format-specific settings), they will be ignored.

The default implementation returns null.

Parameters
imageTypean ImageTypeSpecifier indicating the type of image to be written, or null.
paramthe ImageWriteParam that will be used for writing, or null.
streamMetadataan IIOMetadata object that will be used for writing, or null.
imageMetadataan IIOMetadata object that will be used for writing, or null.
Return
an array of Dimensions with an even length of at least two, or null.
Returns a hash code value for the object. This method is supported for the benefit of hashtables such as those provided by java.util.Hashtable.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hashtables.

As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the JavaTM programming language.)

Return
a hash code value for this object.
Wakes up a single thread that is waiting on this object's monitor. If any threads are waiting on this object, one of them is chosen to be awakened. The choice is arbitrary and occurs at the discretion of the implementation. A thread waits on an object's monitor by calling one of the wait methods.

The awakened thread will not be able to proceed until the current thread relinquishes the lock on this object. The awakened thread will compete in the usual manner with any other threads that might be actively competing to synchronize on this object; for example, the awakened thread enjoys no reliable privilege or disadvantage in being the next thread to lock this object.

This method should only be called by a thread that is the owner of this object's monitor. A thread becomes the owner of the object's monitor in one of three ways:

  • By executing a synchronized instance method of that object.
  • By executing the body of a synchronized statement that synchronizes on the object.
  • For objects of type Class, by executing a synchronized static method of that class.

Only one thread at a time can own an object's monitor.

Throws
IllegalMonitorStateExceptionif the current thread is not the owner of this object's monitor.
Wakes up all threads that are waiting on this object's monitor. A thread waits on an object's monitor by calling one of the wait methods.

The awakened threads will not be able to proceed until the current thread relinquishes the lock on this object. The awakened threads will compete in the usual manner with any other threads that might be actively competing to synchronize on this object; for example, the awakened threads enjoy no reliable privilege or disadvantage in being the next thread to lock this object.

This method should only be called by a thread that is the owner of this object's monitor. See the notify method for a description of the ways in which a thread can become the owner of a monitor.

Throws
IllegalMonitorStateExceptionif the current thread is not the owner of this object's monitor.
Begins the insertion of a new image with undefined pixel values into an existing image stream. Existing images with an index greater than imageIndex are preserved, and their indices are each increased by 1. A value for imageIndex of -1 may be used to signify an index one larger than the previous largest index; that is, it will cause the image to be logically appended to the end of the sequence. If the output is an ImageOutputStream, the entirety of the stream must be both readable and writeable.

The image contents may be supplied later using the replacePixels method. The insertion is not complete until a call to endInsertEmpty occurs. Calls to prepareReplacePixels, replacePixels, and endReplacePixels may occur between calls to prepareInsertEmpty and endInsertEmpty. However, calls to prepareInsertEmpty cannot be nested, and calls to prepareWriteEmpty and prepareInsertEmpty may not be interspersed.

If canInsertEmpty(imageIndex) returns false, an UnsupportedOperationException will be thrown.

An ImageWriteParam may optionally be supplied to control the writing process. If param is null, a default write param will be used.

If the supplied ImageWriteParam contains optional setting values not supported by this writer (e.g. progressive encoding or any format-specific settings), they will be ignored.

The default implementation throws an IllegalStateException if the output is null, and otherwise throws an UnsupportedOperationException.

Parameters
imageIndexthe index at which to write the image.
imageTypean ImageTypeSpecifier describing the layout of the image.
widththe width of the image.
heightthe height of the image.
imageMetadataan IIOMetadata object representing image metadata, or null.
thumbnailsa List of BufferedImage thumbnails for this image, or null.
paraman ImageWriteParam, or null to use a default ImageWriteParam.
Throws
IllegalStateExceptionif the output has not been set.
UnsupportedOperationExceptionif canInsertEmpty(imageIndex) returns false.
IndexOutOfBoundsExceptionif imageIndex is less than -1 or greater than the largest available index.
IllegalStateExceptionif a previous call to prepareInsertEmpty has been made without a corresponding call to endInsertEmpty.
IllegalStateExceptionif a previous call to prepareWriteEmpty has been made without a corresponding call to endWriteEmpty.
IllegalArgumentExceptionif imageType is null or thumbnails contains null references or objects other than BufferedImages.
IllegalArgumentExceptionif width or height are less than 1.
IOExceptionif an I/O error occurs during writing.
Prepares the writer to handle a series of calls to the replacePixels methods. The affected pixel area will be clipped against the supplied

If canReplacePixels returns false, and UnsupportedOperationException will be thrown.

The default implementation throws an IllegalStateException if the output is null, and otherwise throws an UnsupportedOperationException.

Parameters
imageIndexthe index of the image whose pixels are to be replaced.
regiona Rectangle that will be used to clip future pixel regions.
Throws
IllegalStateExceptionif the output has not been set.
UnsupportedOperationExceptionif canReplacePixels(imageIndex) returns false.
IndexOutOfBoundsExceptionif imageIndex is less than 0 or greater than the largest available index.
IllegalStateExceptionif there is a previous call to prepareReplacePixels without a matching call to endReplacePixels (i.e., nesting is not allowed).
IllegalArgumentExceptionif region is null or has a width or height less than 1.
IOExceptionif an I/O error occurs during the preparation.
Begins the writing of a complete image stream, consisting of a single image with undefined pixel values and associated metadata and thumbnails, to the output. The pixel values will be defined by future calls to the replacePixels methods. If the output is an ImageOutputStream, its existing contents prior to the current seek position are not affected, and need not be readable or writable.

The writing is not complete until a call to endWriteEmpty occurs. Calls to prepareReplacePixels, replacePixels, and endReplacePixels may occur between calls to prepareWriteEmpty and endWriteEmpty. However, calls to prepareWriteEmpty cannot be nested, and calls to prepareWriteEmpty and prepareInsertEmpty may not be interspersed.

If canWriteEmpty returns false, an UnsupportedOperationException will be thrown.

An ImageWriteParam may optionally be supplied to control the writing process. If param is null, a default write param will be used.

If the supplied ImageWriteParam contains optional setting values not supported by this writer (e.g. progressive encoding or any format-specific settings), they will be ignored.

The default implementation throws an IllegalStateException if the output is null, and otherwise throws an UnsupportedOperationException.

Parameters
streamMetadataan IIOMetadata object representing stream metadata, or null to use default values.
imageTypean ImageTypeSpecifier describing the layout of the image.
widththe width of the image.
heightthe height of the image.
imageMetadataan IIOMetadata object representing image metadata, or null.
thumbnailsa List of BufferedImage thumbnails for this image, or null.
paraman ImageWriteParam, or null to use a default ImageWriteParam.
Throws
IllegalStateExceptionif the output has not been set.
UnsupportedOperationExceptionif canWriteEmpty returns false.
IllegalStateExceptionif a previous call to prepareWriteEmpty has been made without a corresponding call to endWriteEmpty.
IllegalStateExceptionif a previous call to prepareInsertEmpty has been made without a corresponding call to endInsertEmpty.
IllegalArgumentExceptionif imageType is null or thumbnails contains null references or objects other than BufferedImages.
IllegalArgumentExceptionif width or height are less than 1.
IOExceptionif an I/O error occurs during writing.
Prepares a stream to accept a series of subsequent writeToSequence calls, using the provided stream metadata object. The metadata will be written to the stream if it should precede the image data. If the argument is null, default stream metadata is used.

If the output is an ImageOutputStream, the existing contents of the output prior to the current seek position are flushed, and need not be readable or writable. If the format requires that endWriteSequence be able to rewind to patch up the header information, such as for a sequence of images in a single TIFF file, then the metadata written by this method must remain in a writable portion of the stream. Other formats may flush the stream after this method and after each image.

If canWriteSequence returns false, this method will throw an UnsupportedOperationException.

The output must have been set beforehand using either the setOutput method.

The default implementation throws an IllegalStateException if the output is null, and otherwise throws an UnsupportedOperationException.

Parameters
streamMetadataA stream metadata object, or null.
Throws
IllegalStateExceptionif the output has not been set.
UnsupportedOperationExceptionif canWriteSequence returns false.
IOExceptionif an error occurs writing the stream metadata.
Removes all currently registered IIOWriteProgressListener objects.

The default implementation sets the progressListeners instance variable to null.

Removes all currently registered IIOWriteWarningListener objects.

The default implementation sets the warningListeners and warningLocales instance variables to null.

Removes an IIOWriteProgressListener from the list of registered progress listeners. If the listener was not previously registered, or if listener is null, no exception will be thrown and no action will be taken.
Parameters
listeneran IIOWriteProgressListener to be deregistered.
Removes an IIOWriteWarningListener from the list of registered warning listeners. If the listener was not previously registered, or if listener is null, no exception will be thrown and no action will be taken.
Parameters
listeneran IIOWriteWarningListener to be deregistered.
Removes an image from the stream.

If canRemoveImage(imageIndex) returns false, an UnsupportedOperationExceptionwill be thrown.

The removal may or may not cause a reduction in the actual file size.

The default implementation throws an IllegalStateException if the output is null, and otherwise throws an UnsupportedOperationException.

Parameters
imageIndexthe index of the image to be removed.
Throws
IllegalStateExceptionif the output has not been set.
UnsupportedOperationExceptionif canRemoveImage(imageIndex) returns false.
IndexOutOfBoundsExceptionif imageIndex is less than 0 or greater than the largest available index.
IOExceptionif an I/O error occurs during the removal.
Replaces the image metadata associated with an existing image.

If canReplaceImageMetadata(imageIndex) returns false, an UnsupportedOperationException will be thrown.

The default implementation throws an IllegalStateException if the output is null, and otherwise throws an UnsupportedOperationException.

Parameters
imageIndexthe index of the image whose metadata is to be replaced.
imageMetadataan IIOMetadata object representing image metadata, or null.
Throws
IllegalStateExceptionif the output has not been set.
UnsupportedOperationExceptionif canReplaceImageMetadata returns false.
IndexOutOfBoundsExceptionif imageIndex is less than 0 or greater than the largest available index.
IOExceptionif an error occurs during writing.
Replaces a portion of an image already present in the output with a portion of the given Raster. The image data must match, or be convertible to, the image layout of the existing image.

An ImageWriteParam may optionally be supplied to control the writing process. If param is null, a default write param will be used.

The destination region is specified in the param argument, and will be clipped to the image boundaries and the region supplied to prepareReplacePixels. At least one pixel of the source must not be clipped, or an exception is thrown.

If the supplied ImageWriteParam contains optional setting values not supported by this writer (e.g. progressive encoding or any format-specific settings), they will be ignored.

This method may only be called after a call to prepareReplacePixels, or else an IllegalStateException will be thrown.

The default implementation throws an IllegalStateException if the output is null, and otherwise throws an UnsupportedOperationException.

Parameters
rastera Raster containing source pixels.
paraman ImageWriteParam, or null to use a default ImageWriteParam.
Throws
IllegalStateExceptionif the output has not been set.
UnsupportedOperationExceptionif canReplacePixels(imageIndex) returns false.
IllegalStateExceptionif there is no previous call to prepareReplacePixels without a matching call to endReplacePixels.
UnsupportedOperationExceptionif canWriteRasters returns false.
IllegalArgumentExceptionif any of the following are true:
  • raster is null.
  • param is null.
  • the intersected region does not contain at least one pixel.
  • the layout of raster does not match, or this writer cannot convert it to, the existing image layout.
  • IOExceptionif an I/O error occurs during writing.
    Replaces a portion of an image already present in the output with a portion of the given image. The image data must match, or be convertible to, the image layout of the existing image.

    The destination region is specified in the param argument, and will be clipped to the image boundaries and the region supplied to prepareReplacePixels. At least one pixel of the source must not be clipped, or an exception is thrown.

    An ImageWriteParam may optionally be supplied to control the writing process. If param is null, a default write param will be used.

    If the supplied ImageWriteParam contains optional setting values not supported by this writer (e.g. progressive encoding or any format-specific settings), they will be ignored.

    This method may only be called after a call to prepareReplacePixels, or else an IllegalStateException will be thrown.

    The default implementation throws an IllegalStateException if the output is null, and otherwise throws an UnsupportedOperationException.

    Parameters
    imagea RenderedImage containing source pixels.
    paraman ImageWriteParam, or null to use a default ImageWriteParam.
    Throws
    IllegalStateExceptionif the output has not been set.
    UnsupportedOperationExceptionif canReplacePixels(imageIndex) returns false.
    IllegalStateExceptionif there is no previous call to prepareReplacePixels without a matching call to endReplacePixels.
    IllegalArgumentExceptionif any of the following are true:
  • image is null.
  • param is null.
  • the intersected region does not contain at least one pixel.
  • the layout of image does not match, or this writer cannot convert it to, the existing image layout.
  • IOExceptionif an I/O error occurs during writing.
    Replaces the stream metadata in the output with new information. If the output is an ImageOutputStream, the prior contents of the stream are examined and possibly edited to make room for the new data. All of the prior contents of the output must be available for reading and writing.

    If canReplaceStreamMetadata returns false, an UnsupportedOperationException will be thrown.

    The default implementation throws an IllegalStateException if the output is null, and otherwise throws an UnsupportedOperationException.

    Parameters
    streamMetadataan IIOMetadata object representing stream metadata, or null to use default values.
    Throws
    IllegalStateExceptionif the output has not been set.
    UnsupportedOperationExceptionif the canReplaceStreamMetadata returns false. modes do not include
    IOExceptionif an error occurs during writing.
    Restores the ImageWriter to its initial state.

    The default implementation calls setOutput(null), setLocale(null), removeAllIIOWriteWarningListeners(), removeAllIIOWriteProgressListeners(), and clearAbortRequest.

    Sets the current Locale of this ImageWriter to the given value. A value of null removes any previous setting, and indicates that the writer should localize as it sees fit.

    The default implementation checks locale against the values returned by getAvailableLocales, and sets the locale instance variable if it is found. If locale is null, the instance variable is set to null without any checking.

    Parameters
    localethe desired Locale, or null.
    Throws
    IllegalArgumentExceptionif locale is non-null but is not one of the values returned by getAvailableLocales.
    See Also
    Sets the destination to the given ImageOutputStream or other Object. The destination is assumed to be ready to accept data, and will not be closed at the end of each write. This allows distributed imaging applications to transmit a series of images over a single network connection. If output is null, any currently set output will be removed.

    If output is an ImageOutputStream, calls to the write, writeToSequence, and prepareWriteEmpty/endWriteEmpty methods will preserve the existing contents of the stream. Other write methods, such as writeInsert, replaceStreamMetadata, replaceImageMetadata, replacePixels, prepareInsertEmpty/endInsertEmpty, and endWriteSequence, require the full contents of the stream to be readable and writable, and may alter any portion of the stream.

    Use of a general Object other than an ImageOutputStream is intended for writers that interact directly with an output device or imaging protocol. The set of legal classes is advertised by the writer's service provider's getOutputTypes method; most writers will return a single-element array containing only ImageOutputStream.class to indicate that they accept only an ImageOutputStream.

    The default implementation sets the output instance variable to the value of output after checking output against the set of classes advertised by the originating provider, if there is one.

    Parameters
    outputthe ImageOutputStream or other Object to use for future writing.
    Throws
    IllegalArgumentExceptionif output is not an instance of one of the classes returned by the originating service provider's getOutputTypes method.
    See Also
    Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

    The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

     getClass().getName() + '@' + Integer.toHexString(hashCode())
     
    Return
    a string representation of the object.
    Causes current thread to wait until another thread invokes the method or the method for this object. In other words, this method behaves exactly as if it simply performs the call wait(0).

    The current thread must own this object's monitor. The thread releases ownership of this monitor and waits until another thread notifies threads waiting on this object's monitor to wake up either through a call to the notify method or the notifyAll method. The thread then waits until it can re-obtain ownership of the monitor and resumes execution.

    As in the one argument version, interrupts and spurious wakeups are possible, and this method should always be used in a loop:

         synchronized (obj) {
             while (<condition does not hold>)
                 obj.wait();
             ... // Perform action appropriate to condition
         }
     
    This method should only be called by a thread that is the owner of this object's monitor. See the notify method for a description of the ways in which a thread can become the owner of a monitor.
    Throws
    IllegalMonitorStateExceptionif the current thread is not the owner of the object's monitor.
    InterruptedExceptionif another thread interrupted the current thread before or while the current thread was waiting for a notification. The interrupted status of the current thread is cleared when this exception is thrown.
    Causes current thread to wait until either another thread invokes the method or the method for this object, or a specified amount of time has elapsed.

    The current thread must own this object's monitor.

    This method causes the current thread (call it T) to place itself in the wait set for this object and then to relinquish any and all synchronization claims on this object. Thread T becomes disabled for thread scheduling purposes and lies dormant until one of four things happens:

    • Some other thread invokes the notify method for this object and thread T happens to be arbitrarily chosen as the thread to be awakened.
    • Some other thread invokes the notifyAll method for this object.
    • Some other thread interrupts thread T.
    • The specified amount of real time has elapsed, more or less. If timeout is zero, however, then real time is not taken into consideration and the thread simply waits until notified.
    The thread T is then removed from the wait set for this object and re-enabled for thread scheduling. It then competes in the usual manner with other threads for the right to synchronize on the object; once it has gained control of the object, all its synchronization claims on the object are restored to the status quo ante - that is, to the situation as of the time that the wait method was invoked. Thread T then returns from the invocation of the wait method. Thus, on return from the wait method, the synchronization state of the object and of thread T is exactly as it was when the wait method was invoked.

    A thread can also wake up without being notified, interrupted, or timing out, a so-called spurious wakeup. While this will rarely occur in practice, applications must guard against it by testing for the condition that should have caused the thread to be awakened, and continuing to wait if the condition is not satisfied. In other words, waits should always occur in loops, like this one:

         synchronized (obj) {
             while (<condition does not hold>)
                 obj.wait(timeout);
             ... // Perform action appropriate to condition
         }
     
    (For more information on this topic, see Section 3.2.3 in Doug Lea's "Concurrent Programming in Java (Second Edition)" (Addison-Wesley, 2000), or Item 50 in Joshua Bloch's "Effective Java Programming Language Guide" (Addison-Wesley, 2001).

    If the current thread is interrupted by another thread while it is waiting, then an InterruptedException is thrown. This exception is not thrown until the lock status of this object has been restored as described above.

    Note that the wait method, as it places the current thread into the wait set for this object, unlocks only this object; any other objects on which the current thread may be synchronized remain locked while the thread waits.

    This method should only be called by a thread that is the owner of this object's monitor. See the notify method for a description of the ways in which a thread can become the owner of a monitor.

    Parameters
    timeoutthe maximum time to wait in milliseconds.
    Throws
    IllegalArgumentExceptionif the value of timeout is negative.
    IllegalMonitorStateExceptionif the current thread is not the owner of the object's monitor.
    InterruptedExceptionif another thread interrupted the current thread before or while the current thread was waiting for a notification. The interrupted status of the current thread is cleared when this exception is thrown.
    Causes current thread to wait until another thread invokes the method or the method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.

    This method is similar to the wait method of one argument, but it allows finer control over the amount of time to wait for a notification before giving up. The amount of real time, measured in nanoseconds, is given by:

     1000000*timeout+nanos

    In all other respects, this method does the same thing as the method of one argument. In particular, wait(0, 0) means the same thing as wait(0).

    The current thread must own this object's monitor. The thread releases ownership of this monitor and waits until either of the following two conditions has occurred:

    • Another thread notifies threads waiting on this object's monitor to wake up either through a call to the notify method or the notifyAll method.
    • The timeout period, specified by timeout milliseconds plus nanos nanoseconds arguments, has elapsed.

    The thread then waits until it can re-obtain ownership of the monitor and resumes execution.

    As in the one argument version, interrupts and spurious wakeups are possible, and this method should always be used in a loop:

         synchronized (obj) {
             while (<condition does not hold>)
                 obj.wait(timeout, nanos);
             ... // Perform action appropriate to condition
         }
     
    This method should only be called by a thread that is the owner of this object's monitor. See the notify method for a description of the ways in which a thread can become the owner of a monitor.
    Parameters
    timeoutthe maximum time to wait in milliseconds.
    nanosadditional time, in nanoseconds range 0-999999.
    Throws
    IllegalArgumentExceptionif the value of timeout is negative or the value of nanos is not in the range 0-999999.
    IllegalMonitorStateExceptionif the current thread is not the owner of this object's monitor.
    InterruptedExceptionif another thread interrupted the current thread before or while the current thread was waiting for a notification. The interrupted status of the current thread is cleared when this exception is thrown.
    Appends a complete image stream containing a single image with default metadata and thumbnails to the output. This method is a shorthand for write(null, image, null).
    Parameters
    imagean IIOImage object containing an image, thumbnails, and metadata to be written.
    Throws
    IllegalStateExceptionif the output has not been set.
    IllegalArgumentExceptionif image is null.
    UnsupportedOperationExceptionif image contains a Raster and canWriteRasters returns false.
    IOExceptionif an error occurs during writing.
    Appends a complete image stream containing a single image and associated stream and image metadata and thumbnails to the output. Any necessary header information is included. If the output is an ImageOutputStream, its existing contents prior to the current seek position are not affected, and need not be readable or writable.

    The output must have been set beforehand using the setOutput method.

    Stream metadata may optionally be supplied; if it is null, default stream metadata will be used.

    If canWriteRasters returns true, the IIOImage may contain a Raster source. Otherwise, it must contain a RenderedImage source.

    The supplied thumbnails will be resized if needed, and any thumbnails in excess of the supported number will be ignored. If the format requires additional thumbnails that are not provided, the writer should generate them internally.

    An ImageWriteParam may optionally be supplied to control the writing process. If param is null, a default write param will be used.

    If the supplied ImageWriteParam contains optional setting values not supported by this writer (e.g. progressive encoding or any format-specific settings), they will be ignored.

    Parameters
    streamMetadataan IIOMetadata object representing stream metadata, or null to use default values.
    imagean IIOImage object containing an image, thumbnails, and metadata to be written.
    paraman ImageWriteParam, or null to use a default ImageWriteParam.
    Throws
    IllegalStateExceptionif the output has not been set.
    UnsupportedOperationExceptionif image contains a Raster and canWriteRasters returns false.
    IllegalArgumentExceptionif image is null.
    IOExceptionif an error occurs during writing.
    Appends a complete image stream consisting of a single image with default metadata and thumbnails to the output. This method is a shorthand for write(null, new IIOImage(image, null, null), null).
    Parameters
    imagea RenderedImage to be written.
    Throws
    IllegalStateExceptionif the output has not been set.
    IllegalArgumentExceptionif image is null.
    IOExceptionif an error occurs during writing.
    Inserts a new image into an existing image stream. Existing images with an index greater than imageIndex are preserved, and their indices are each increased by 1. A value for imageIndex of -1 may be used to signify an index one larger than the previous largest index; that is, it will cause the image to be logically appended to the end of the sequence. If the output is an ImageOutputStream, the entirety of the stream must be both readable and writeable.

    If canInsertImage(imageIndex) returns false, an UnsupportedOperationException will be thrown.

    An ImageWriteParam may optionally be supplied to control the writing process. If param is null, a default write param will be used.

    If the supplied ImageWriteParam contains optional setting values not supported by this writer (e.g. progressive encoding or any format-specific settings), they will be ignored.

    The default implementation throws an IllegalStateException if the output is null, and otherwise throws an UnsupportedOperationException.

    Parameters
    imageIndexthe index at which to write the image.
    imagean IIOImage object containing an image, thumbnails, and metadata to be written.
    paraman ImageWriteParam, or null to use a default ImageWriteParam.
    Throws
    IllegalStateExceptionif the output has not been set.
    UnsupportedOperationExceptionif canInsertImage(imageIndex) returns false.
    IllegalArgumentExceptionif image is null.
    IndexOutOfBoundsExceptionif imageIndex is less than -1 or greater than the largest available index.
    UnsupportedOperationExceptionif image contains a Raster and canWriteRasters returns false.
    IOExceptionif an error occurs during writing.
    Appends a single image and possibly associated metadata and thumbnails, to the output. If the output is an ImageOutputStream, the existing contents of the output prior to the current seek position may be flushed, and need not be readable or writable, unless the plug-in needs to be able to patch up the header information when endWriteSequence is called (e.g. TIFF).

    If canWriteSequence returns false, this method will throw an UnsupportedOperationException.

    The output must have been set beforehand using the setOutput method.

    prepareWriteSequence must have been called beforehand, or an IllegalStateException is thrown.

    If canWriteRasters returns true, the IIOImage may contain a Raster source. Otherwise, it must contain a RenderedImage source.

    The supplied thumbnails will be resized if needed, and any thumbnails in excess of the supported number will be ignored. If the format requires additional thumbnails that are not provided, the writer will generate them internally.

    An ImageWriteParam may optionally be supplied to control the writing process. If param is null, a default write param will be used.

    If the supplied ImageWriteParam contains optional setting values not supported by this writer (e.g. progressive encoding or any format-specific settings), they will be ignored.

    The default implementation throws an IllegalStateException if the output is null, and otherwise throws an UnsupportedOperationException.

    Parameters
    imagean IIOImage object containing an image, thumbnails, and metadata to be written.
    paraman ImageWriteParam, or null to use a default ImageWriteParam.
    Throws
    IllegalStateExceptionif the output has not been set, or prepareWriteSequence has not been called.
    UnsupportedOperationExceptionif canWriteSequence returns false.
    IllegalArgumentExceptionif image is null.
    UnsupportedOperationExceptionif image contains a Raster and canWriteRasters returns false.
    IOExceptionif an error occurs during writing.