A class describing how a stream is to be encoded. Instances of this class or its subclasses are used to supply prescriptive "how-to" information to instances of ImageWriter.

A plug-in for a specific image format may define a subclass of this class, and return objects of that class from the getDefaultWriteParam method of its ImageWriter implementation. For example, the built-in JPEG writer plug-in will return instances of javax.imageio.plugins.jpeg.JPEGImageWriteParam.

The region of the image to be written is determined by first intersecting the actual bounds of the image with the rectangle specified by IIOParam.setSourceRegion, if any. If the resulting rectangle has a width or height of zero, the writer will throw an IIOException. If the intersection is non-empty, writing will commence with the first subsampled pixel and include additional pixels within the intersected bounds according to the horizontal and vertical subsampling factors specified by IIOParam.setSourceSubsampling .

Individual features such as tiling, progressive encoding, and compression may be set in one of four modes. MODE_DISABLED disables the features; MODE_DEFAULT enables the feature with writer-controlled parameter values; MODE_EXPLICIT enables the feature and allows the use of a set method to provide additional parameters; and MODE_COPY_FROM_METADATA copies relevant parameter values from the stream and image metadata objects passed to the writer. The default for all features is MODE_COPY_FROM_METADATA. Non-standard features supplied in subclasses are encouraged, but not required to use a similar scheme.

Plug-in writers may extend the functionality of ImageWriteParam by providing a subclass that implements additional, plug-in specific interfaces. It is up to the plug-in to document what interfaces are available and how they are to be used. Writers will silently ignore any extended features of an ImageWriteParam subclass of which they are not aware. Also, they may ignore any optional features that they normally disable when creating their own ImageWriteParam instances via getDefaultWriteParam.

Note that unless a query method exists for a capability, it must be supported by all ImageWriter implementations (e.g. progressive encoding is optional, but subsampling must be supported).

@version
0.5
Constructs an ImageWriteParam set to use a given Locale.
Parameters
localea Locale to be used to localize compression type names and quality descriptions, or null.
A constant value that may be passed into methods such as setTilingMode, setProgressiveMode, or setCompressionMode to enable that feature for future writes. That is, when this mode is enabled the stream will be tiled, progressive, or compressed based on the contents of stream and/or image metadata passed into the write operation, and any relevant accessor methods will throw an IllegalStateException.

This is the default mode for all features, so that a read including metadata followed by a write including metadata will preserve as much information as possible.

A constant value that may be passed into methods such as setTilingMode, setProgressiveMode, and setCompressionMode to enable that feature for future writes. That is, when this mode is enabled the stream will be tiled, progressive, or compressed according to a sensible default chosen internally by the writer in a plug-in dependent way, and the relevant accessor methods will throw an IllegalStateException.
A constant value that may be passed into methods such as setTilingMode, setProgressiveMode, and setCompressionMode to disable a feature for future writes. That is, when this mode is set the stream will not be tiled, progressive, or compressed, and the relevant accessor methods will throw an IllegalStateException.
A constant value that may be passed into methods such as setTilingMode or setCompressionMode to enable a feature for future writes. That is, when this mode is set the stream will be tiled or compressed according to additional information supplied to the corresponding set methods in this class and retrievable from the corresponding get methods. Note that this mode is not supported for progressive output.
Activates the installed IIOParamController for this IIOParam object and returns the resulting value. When this method returns true, all values for this IIOParam object will be ready for the next read or write operation. If false is returned, no settings in this object will have been disturbed (i.e., the user canceled the operation).

Ordinarily, the controller will be a GUI providing a user interface for a subclass of IIOParam for a particular plug-in. Controllers need not be GUIs, however.

Return
true if the controller completed normally.
Throws
IllegalStateExceptionif there is no controller currently installed.
Returns true if the writer can perform tiling with non-zero grid offsets while writing. If this method returns false, then setTiling will throw an UnsupportedOperationException if the grid offset arguments are not both zero. If canWriteTiles returns false, this method will return false as well.
Return
true if the writer supports non-zero tile offsets.
Returns true if this writer supports compression.
Return
true if the writer supports compression.
Returns true if the writer can write out images as a series of passes of progressively increasing quality.
Return
true if the writer supports progressive encoding.
Returns true if the writer can perform tiling while writing. If this method returns false, then setTiling will throw an UnsupportedOperationException.
Return
true if the writer supports tiling.
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 a float indicating an estimate of the number of bits of output data for each bit of input image data at the given quality level. The value will typically lie between 0 and 1, with smaller values indicating more compression. A special value of -1.0F is used to indicate that no estimate is available.

If there are multiple compression types but none has been set, an IllegalStateException is thrown.

The default implementation checks that compression is supported and the compression mode is MODE_EXPLICIT. If so, if getCompressionTypes() is null or getCompressionType() is non-null, and quality is within bounds, it returns -1.0.

Parameters
qualitythe quality setting whose bit rate is to be queried.
Return
an estimate of the compressed bit rate, or -1.0F if no estimate is available.
Throws
UnsupportedOperationExceptionif the writer does not support compression.
IllegalStateExceptionif the compression mode is not MODE_EXPLICIT.
IllegalStateExceptionif the set of legal compression types is non-null and the current compression type is null.
IllegalArgumentExceptionif quality is not between 0and 1, inclusive.
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 the current compression mode, if compression is supported.
Return
the current compression mode.
Throws
UnsupportedOperationExceptionif the writer does not support compression.
Returns the current compression quality setting.

If there are multiple compression types but none has been set, an IllegalStateException is thrown.

The default implementation checks that compression is supported and that the compression mode is MODE_EXPLICIT. If so, if getCompressionTypes() is null or getCompressionType() is non-null, it returns the value of the compressionQuality instance variable.

Return
the current compression quality setting.
Throws
UnsupportedOperationExceptionif the writer does not support compression.
IllegalStateExceptionif the compression mode is not MODE_EXPLICIT.
IllegalStateExceptionif the set of legal compression types is non-null and the current compression type is null.
Returns an array of Strings that may be used along with getCompressionQualityValues as part of a user interface for setting or displaying the compression quality level. The String with index i provides a description of the range of quality levels between getCompressionQualityValues[i] and getCompressionQualityValues[i + 1]. Note that the length of the array returned from getCompressionQualityValues will always be one greater than that returned from getCompressionQualityDescriptions.

As an example, the strings "Good", "Better", and "Best" could be associated with the ranges [0, .33), [.33, .66), and [.66, 1.0]. In this case, getCompressionQualityDescriptions would return { "Good", "Better", "Best" } and getCompressionQualityValues would return { 0.0F, .33F, .66F, 1.0F }.

If no descriptions are available, null is returned. If null is returned from getCompressionQualityValues, this method must also return null.

The descriptions should be localized for the Locale returned by getLocale, if it is non-null.

If there are multiple compression types but none has been set, an IllegalStateException is thrown.

The default implementation checks that compression is supported and that the compression mode is MODE_EXPLICIT. If so, if getCompressionTypes() is null or getCompressionType() is non-null, it returns null.

Return
an array of Strings containing localized descriptions of the compression quality levels.
Throws
UnsupportedOperationExceptionif the writer does not support compression.
IllegalStateExceptionif the compression mode is not MODE_EXPLICIT.
IllegalStateExceptionif the set of legal compression types is non-null and the current compression type is null.
Returns an array of floats that may be used along with getCompressionQualityDescriptions as part of a user interface for setting or displaying the compression quality level. See getCompressionQualityDescriptions for more information.

If no descriptions are available, null is returned. If null is returned from getCompressionQualityDescriptions, this method must also return null.

If there are multiple compression types but none has been set, an IllegalStateException is thrown.

The default implementation checks that compression is supported and that the compression mode is MODE_EXPLICIT. If so, if getCompressionTypes() is null or getCompressionType() is non-null, it returns null.

Return
an array of floats indicating the boundaries between the compression quality levels as described by the Strings from getCompressionQualityDescriptions.
Throws
UnsupportedOperationExceptionif the writer does not support compression.
IllegalStateExceptionif the compression mode is not MODE_EXPLICIT.
IllegalStateExceptionif the set of legal compression types is non-null and the current compression type is null.
Returns the currently set compression type, or null if none has been set. The type is returned as a String from among those returned by getCompressionTypes. If no compression type has been set, null is returned.

The default implementation checks whether compression is supported and the compression mode is MODE_EXPLICIT. If so, it returns the value of the compressionType instance variable.

Return
the current compression type as a String, or null if no type is set.
Throws
UnsupportedOperationExceptionif the writer does not support compression.
IllegalStateExceptionif the compression mode is not MODE_EXPLICIT.
Returns a list of available compression types, as an array or Strings, or null if a compression type may not be chosen using these interfaces. The array returned is a copy.

If the writer only offers a single, mandatory form of compression, it is not necessary to provide any named compression types. Named compression types should only be used where the user is able to make a meaningful choice between different schemes.

The default implementation checks if compression is supported and throws an UnsupportedOperationException if not. Otherwise, it returns a clone of the compressionTypes instance variable if it is non-null, or else returns null.

Return
an array of Strings containing the (non-localized) names of available compression types, or null.
Throws
UnsupportedOperationExceptionif the writer does not support compression.
Returns whatever IIOParamController is currently installed. This could be the default if there is one, null, or the argument of the most recent call to setController.
Return
the currently installed IIOParamController, or null.
Returns the default IIOParamController, if there is one, regardless of the currently installed controller. If there is no default controller, returns null.
Return
the default IIOParamController, or null.
Returns the offset in the destination image at which pixels are to be placed.

If setDestinationOffsets has not been called, a Point with zero X and Y values is returned (which is the correct value).

Return
the destination offset as a Point.
Returns the type of image to be returned by the read, if one was set by a call to setDestination(ImageTypeSpecifier), as an ImageTypeSpecifier. If none was set, null is returned.
Return
an ImageTypeSpecifier describing the destination type, or null.
Returns the currently set Locale, or null if only a default Locale is supported.
Return
the current Locale, or null.
Returns a localized version of the name of the current compression type, using the Locale returned by getLocale.

The default implementation checks whether compression is supported and the compression mode is MODE_EXPLICIT. If so, if compressionType is non-null the value of getCompressionType is returned as a convenience.

Return
a String containing a localized version of the name of the current compression type.
Throws
UnsupportedOperationExceptionif the writer does not support compression.
IllegalStateExceptionif the compression mode is not MODE_EXPLICIT.
IllegalStateExceptionif no compression type is set.
Returns an array of Dimensions indicating the legal size ranges for tiles as they will be encoded in the output file or stream. The returned array is a copy.

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, use the same width and height for both elements. To specify an arbitrary range, a value of null is used in place of an actual array of Dimensions.

If no array is specified on the constructor, but tiling is allowed, then this method returns null.

Return
an array of Dimensions with an even length of at least two, or null.
Throws
UnsupportedOperationExceptionif the plug-in does not support tiling.
Returns the current mode for writing the stream in a progressive manner.
Return
the current mode for progressive encoding.
Throws
UnsupportedOperationExceptionif the writer does not support progressive encoding.
Returns the set of of source bands to be used. The returned value is that set by the most recent call to setSourceBands, or null if there have been no calls to setSourceBands.

Semantically, the array returned is a copy; changes to array contents subsequent to this call have no effect on this IIOParam.

Return
the set of source bands to be used, or null.
Returns the source region to be used. The returned value is that set by the most recent call to setSourceRegion, and will be null if there is no region set.
Return
the source region of interest as a Rectangle, or null.
Returns the number of source columns to advance for each pixel.

If setSourceSubsampling has not been called, 1 is returned (which is the correct value).

Return
the source subsampling X period.
Returns the number of rows to advance for each pixel.

If setSourceSubsampling has not been called, 1 is returned (which is the correct value).

Return
the source subsampling Y period.
Returns the horizontal offset of the subsampling grid.

If setSourceSubsampling has not been called, 0 is returned (which is the correct value).

Return
the source subsampling grid X offset.
Returns the vertical offset of the subsampling grid.

If setSourceSubsampling has not been called, 0 is returned (which is the correct value).

Return
the source subsampling grid Y offset.
Returns the horizontal tile grid offset of an image as it will be written to the output stream. If tiling parameters have not been set, an IllegalStateException is thrown.
Return
the tile grid X offset to be used for encoding.
Throws
UnsupportedOperationExceptionif the plug-in does not support tiling.
IllegalStateExceptionif the tiling mode is not MODE_EXPLICIT.
IllegalStateExceptionif the tiling parameters have not been set.
Returns the vertical tile grid offset of an image as it will be written to the output stream. If tiling parameters have not been set, an IllegalStateException is thrown.
Return
the tile grid Y offset to be used for encoding.
Throws
UnsupportedOperationExceptionif the plug-in does not support tiling.
IllegalStateExceptionif the tiling mode is not MODE_EXPLICIT.
IllegalStateExceptionif the tiling parameters have not been set.
Returns the height of each tile in an image as it will be written to the output stream. If tiling parameters have not been set, an IllegalStateException is thrown.
Return
the tile height to be used for encoding.
Throws
UnsupportedOperationExceptionif the plug-in does not support tiling.
IllegalStateExceptionif the tiling mode is not MODE_EXPLICIT.
IllegalStateExceptionif the tiling parameters have not been set.
Returns the width of each tile in an image as it will be written to the output stream. If tiling parameters have not been set, an IllegalStateException is thrown.
Return
the tile width to be used for encoding.
Throws
UnsupportedOperationExceptionif the plug-in does not support tiling.
IllegalStateExceptionif the tiling mode is not MODE_EXPLICIT.
IllegalStateExceptionif the tiling parameters have not been set.
Returns the current tiling mode, if tiling is supported. Otherwise throws an UnsupportedOperationException.
Return
the current tiling mode.
Throws
UnsupportedOperationExceptionif canWriteTiles returns false.
Returns true if there is a controller installed for this IIOParam object. This will return true if getController would not return 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.
Returns true if the current compression type provides lossless compression. If a plug-in provides only one mandatory compression type, then this method may be called without calling setCompressionType first.

If there are multiple compression types but none has been set, an IllegalStateException is thrown.

The default implementation checks whether compression is supported and the compression mode is MODE_EXPLICIT. If so, if getCompressionTypes() is null or getCompressionType() is non-null true is returned as a convenience.

Return
true if the current compression type is lossless.
Throws
UnsupportedOperationExceptionif the writer does not support compression.
IllegalStateExceptionif the compression mode is not MODE_EXPLICIT.
IllegalStateExceptionif the set of legal compression types is non-null and the current compression type is null.
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.
Specifies whether compression is to be performed, and if so how compression parameters are to be determined. The mode argument must be one of the four modes, interpreted as follows:
  • MODE_DISABLED - Do not compress. This may not be permitted by some writers, such as JPEG, which do not normally offer uncompressed output. The corresponding set and get methods will throw an IllegalStateException.
  • MODE_EXPLICIT - Compress using the compression type and quality settings specified in this ImageWriteParam. Any previously set compression parameters are discarded.
  • MODE_COPY_FROM_METADATA - Use whatever compression parameters are specified in metadata objects passed in to the writer.
  • MODE_DEFAULT - Use default compression parameters.

The default is MODE_COPY_FROM_METADATA.

Parameters
modeThe mode for setting compression in the output stream.
Throws
UnsupportedOperationExceptionif the writer does not support compression, or does not support the requested mode.
IllegalArgumentExceptionif mode is not one of the modes listed above.
Sets the compression quality to a value between 0 and 1. Only a single compression quality setting is supported by default; writers can provide extended versions of ImageWriteParam that offer more control. For lossy compression schemes, the compression quality should control the tradeoff between file size and image quality (for example, by choosing quantization tables when writing JPEG images). For lossless schemes, the compression quality may be used to control the tradeoff between file size and time taken to perform the compression (for example, by optimizing row filters and setting the ZLIB compression level when writing PNG images).

A compression quality setting of 0.0 is most generically interpreted as "high compression is important," while a setting of 1.0 is most generically interpreted as "high image quality is important."

If there are multiple compression types but none has been set, an IllegalStateException is thrown.

The default implementation checks that compression is supported, and that the compression mode is MODE_EXPLICIT. If so, if getCompressionTypes() returns null or compressionType is non-null it sets the compressionQuality instance variable.

Parameters
qualitya float between 0and 1 indicating the desired quality level.
Throws
UnsupportedOperationExceptionif the writer does not support compression.
IllegalStateExceptionif the compression mode is not MODE_EXPLICIT.
IllegalStateExceptionif the set of legal compression types is non-null and the current compression type is null.
IllegalArgumentExceptionif quality is not between 0and 1, inclusive.
Sets the compression type to one of the values indicated by getCompressionTypes. If a value of null is passed in, any previous setting is removed.

The default implementation checks whether compression is supported and the compression mode is MODE_EXPLICIT. If so, it calls getCompressionTypes and checks if compressionType is one of the legal values. If it is, the compressionType instance variable is set. If compressionType is null, the instance variable is set without performing any checking.

Parameters
compressionTypeone of the Strings returned by getCompressionTypes, or null to remove any previous setting.
Throws
UnsupportedOperationExceptionif the writer does not support compression.
IllegalStateExceptionif the compression mode is not MODE_EXPLICIT.
UnsupportedOperationExceptionif there are no settable compression types.
IllegalArgumentExceptionif compressionType is non-null but is not one of the values returned by getCompressionTypes.
Sets the IIOParamController to be used to provide settings for this IIOParam object when the activateController method is called, overriding any default controller. If the argument is null, no controller will be used, including any default. To restore the default, use setController(getDefaultController()).
Parameters
controllerAn appropriate IIOParamController, or null.
Specifies the offset in the destination image at which future decoded pixels are to be placed, when reading, or where a region will be written, when writing.

When reading, the region to be written within the destination BufferedImage will start at this offset and have a width and height determined by the source region of interest, the subsampling parameters, and the destination bounds.

Normal writes are not affected by this method, only writes performed using ImageWriter.replacePixels. For such writes, the offset specified is within the output stream image whose pixels are being modified.

There is no unsetDestinationOffset method; simply call setDestinationOffset(new Point(0, 0)) to restore default values.

Parameters
destinationOffsetthe offset in the destination, as a Point.
Throws
IllegalArgumentExceptionif destinationOffset is null.
Sets the desired image type for the destination image, using an ImageTypeSpecifier.

When reading, if the layout of the destination has been set using this method, each call to an ImageReader read method will return a new BufferedImage using the format specified by the supplied type specifier. As a side effect, any destination BufferedImage set by ImageReadParam.setDestination(BufferedImage) will no longer be set as the destination. In other words, this method may be thought of as calling setDestination((BufferedImage)null).

When writing, the destination type maybe used to determine the color type of the image. The SampleModel information will be ignored, and may be null. For example, a 4-banded image could represent either CMYK or RGBA data. If a destination type is set, its ColorModel will override any ColorModel on the image itself. This is crucial when setSourceBands is used since the image's ColorModel will refer to the entire image rather than to the subset of bands being written.

Parameters
destinationTypethe ImageTypeSpecifier to be used to determine the destination layout and color type.
Specifies that the writer is to write the image out in a progressive mode such that the stream will contain a series of scans of increasing quality. If progressive encoding is not supported, an UnsupportedOperationException will be thrown.

The mode argument determines how the progression parameters are chosen, and must be either MODE_DISABLED, MODE_COPY_FROM_METADATA, or MODE_DEFAULT. Otherwise an IllegalArgumentException is thrown.

The modes are interpreted as follows:

  • MODE_DISABLED - No progression. Use this to turn off progession.
  • MODE_COPY_FROM_METADATA - The output image will use whatever progression parameters are found in the metadata objects passed into the writer.
  • MODE_DEFAULT - The image will be written progressively, with parameters chosen by the writer.

The default is MODE_COPY_FROM_METADATA.

Parameters
modeThe mode for setting progression in the output stream.
Throws
UnsupportedOperationExceptionif the writer does not support progressive encoding.
IllegalArgumentExceptionif mode is not one of the modes listed above.
Sets the indices of the source bands to be used. Duplicate indices are not allowed.

A null value indicates that all source bands will be used.

At the time of reading, an IllegalArgumentException will be thrown by the reader or writer if a value larger than the largest available source band index has been specified or if the number of source bands and destination bands to be used differ. The ImageReader.checkReadParamBandSettings method may be used to automate this test.

Semantically, a copy is made of the array; changes to the array contents subsequent to this call have no effect on this IIOParam.

Parameters
sourceBandsan array of integer band indices to be used.
Throws
IllegalArgumentExceptionif sourceBands contains a negative or duplicate value.
Sets the source region of interest. The region of interest is described as a rectangle, with the upper-left corner of the source image as pixel (0, 0) and increasing values down and to the right. The actual number of pixels used will depend on the subsampling factors set by setSourceSubsampling. If subsampling has been set such that this number is zero, an IllegalStateException will be thrown.

The source region of interest specified by this method will be clipped as needed to fit within the source bounds, as well as the destination offsets, width, and height at the time of actual I/O.

A value of null for sourceRegion will remove any region specification, causing the entire image to be used.

Parameters
sourceRegiona Rectangle specifying the source region of interest, or null.
Throws
IllegalArgumentExceptionif sourceRegion is non-null and either sourceRegion.x or sourceRegion.y is negative.
IllegalArgumentExceptionif sourceRegion is non-null and either sourceRegion.width or sourceRegion.height is negative or 0.
IllegalStateExceptionif subsampling is such that this region will have a subsampled width or height of zero.
Specifies a decimation subsampling to apply on I/O. The sourceXSubsampling and sourceYSubsampling parameters specify the subsampling period (i.e., the number of rows and columns to advance after every source pixel). Specifically, a period of 1 will use every row or column; a period of 2 will use every other row or column. The subsamplingXOffset and subsamplingYOffset parameters specify an offset from the region (or image) origin for the first subsampled pixel. Adjusting the origin of the subsample grid is useful for avoiding seams when subsampling a very large source image into destination regions that will be assembled into a complete subsampled image. Most users will want to simply leave these parameters at 0.

The number of pixels and scanlines to be used are calculated as follows.

The number of subsampled pixels in a scanline is given by

truncate[(width - subsamplingXOffset + sourceXSubsampling - 1) / sourceXSubsampling].

If the region is such that this width is zero, an IllegalStateException is thrown.

The number of scanlines to be used can be computed similarly.

The ability to set the subsampling grid to start somewhere other than the source region origin is useful if the region is being used to create subsampled tiles of a large image, where the tile width and height are not multiples of the subsampling periods. If the subsampling grid does not remain consistent from tile to tile, there will be artifacts at the tile boundaries. By adjusting the subsampling grid offset for each tile to compensate, these artifacts can be avoided. The tradeoff is that in order to avoid these artifacts, the tiles are not all the same size. The grid offset to use in this case is given by:
grid offset = [period - (region offset modulo period)] modulo period)

If either sourceXSubsampling or sourceYSubsampling is 0 or negative, an IllegalArgumentException will be thrown.

If either subsamplingXOffset or subsamplingYOffset is negative or greater than or equal to the corresponding period, an IllegalArgumentException will be thrown.

There is no unsetSourceSubsampling method; simply call setSourceSubsampling(1, 1, 0, 0) to restore default values.

Parameters
sourceXSubsamplingthe number of columns to advance between pixels.
sourceYSubsamplingthe number of rows to advance between pixels.
subsamplingXOffsetthe horizontal offset of the first subsample within the region, or within the image if no region is set.
subsamplingYOffsetthe horizontal offset of the first subsample within the region, or within the image if no region is set.
Throws
IllegalArgumentExceptionif either period is negative or 0, or if either grid offset is negative or greater than the corresponding period.
IllegalStateExceptionif the source region is such that the subsampled output would contain no pixels.
Specifies that the image should be tiled in the output stream. The tileWidth and tileHeight parameters specify the width and height of the tiles in the file. If the tile width or height is greater than the width or height of the image, the image is not tiled in that dimension.

If canOffsetTiles returns false, then the tileGridXOffset and tileGridYOffset parameters must be zero.

Parameters
tileWidththe width of each tile.
tileHeightthe height of each tile.
tileGridXOffsetthe horizontal offset of the tile grid.
tileGridYOffsetthe vertical offset of the tile grid.
Throws
UnsupportedOperationExceptionif the plug-in does not support tiling.
IllegalStateExceptionif the tiling mode is not MODE_EXPLICIT.
UnsupportedOperationExceptionif the plug-in does not support grid offsets, and the grid offsets are not both zero.
IllegalArgumentExceptionif the tile size is not within one of the allowable ranges returned by getPreferredTileSizes.
IllegalArgumentExceptionif tileWidth or tileHeight is less than or equal to 0.
Determines whether the image will be tiled in the output stream and, if it will, how the tiling parameters will be determined. The modes are interpreted as follows:
  • MODE_DISABLED - The image will not be tiled. setTiling will throw an IllegalStateException.
  • MODE_DEFAULT - The image will be tiled using default parameters. setTiling will throw an IllegalStateException.
  • MODE_EXPLICIT - The image will be tiled according to parameters given in the setTiling method. Any previously set tiling parameters are discarded.
  • MODE_COPY_FROM_METADATA - The image will conform to the metadata object passed in to a write. setTiling will throw an IllegalStateException.
Parameters
modeThe mode to use for tiling.
Throws
UnsupportedOperationExceptionif canWriteTiles returns false.
IllegalArgumentExceptionif mode is not one of the modes listed above.
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.
Removes any previous compression type and quality settings.

The default implementation sets the instance variable compressionType to null, and the instance variable compressionQuality to 1.0F.

Throws
UnsupportedOperationExceptionif the plug-in does not support compression.
IllegalStateExceptionif the compression mode is not MODE_EXPLICIT.
Removes any previous tile grid parameters specified by calls to setTiling.

The default implementation sets the instance variables tileWidth, tileHeight, tileGridXOffset, and tileGridYOffset to 0.

Throws
UnsupportedOperationExceptionif the plug-in does not support tiling.
IllegalStateExceptionif the tiling mode is not MODE_EXPLICIT.
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.