java.lang.Objectjavax.imageio.IIOParam
javax.imageio.ImageWriteParam
Direct Known Subclasses:
BMPImageWriteParam, JPEGImageWriteParam
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).
Field Summary | ||
---|---|---|
public static final int | MODE_DISABLED | 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 . |
public static final int | MODE_DEFAULT | 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 . |
public static final int | MODE_EXPLICIT | 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. |
public static final int | MODE_COPY_FROM_METADATA | 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. |
protected boolean | canWriteTiles | A boolean that is true if this
ImageWriteParam allows tile width and tile height
parameters to be set. By default, the value is
false . Subclasses must set the value manually.
Subclasses that do not support writing tiles should ensure
that this value is set to |
protected int | tilingMode | The mode controlling tiling settings, which Must be
set to one of the four MODE_* values. The default
is MODE_COPY_FROM_METADATA .
Subclasses that do not writing tiles may ignore this value. |
protected Dimension[] | preferredTileSizes | An array of preferred tile size range pairs. The default value
is null , which indicates that there are no
preferred sizes. If the value is non-null , it
must have an even length of at least two.
Subclasses that do not support writing tiles may ignore this value.
|
protected boolean | tilingSet | A boolean that is true if tiling
parameters have been specified.
Subclasses that do not support writing tiles may ignore this value. |
protected int | tileWidth | The width of each tile if tiling has been set, or 0 otherwise.
Subclasses that do not support tiling may ignore this value. |
protected int | tileHeight | The height of each tile if tiling has been set, or 0 otherwise.
The initial value is 0 .
Subclasses that do not support tiling may ignore this value. |
protected boolean | canOffsetTiles | A boolean that is true if this
ImageWriteParam allows tiling grid offset
parameters to be set. By default, the value is
false . Subclasses must set the value manually.
Subclasses that do not support writing tiles, or that
supprt writing but not offsetting tiles must ensure that this
value is set to |
protected int | tileGridXOffset | The amount by which the tile grid origin should be offset
horizontally from the image origin if tiling has been set,
or 0 otherwise. The initial value is 0 .
Subclasses that do not support offsetting tiles may ignore this value. |
protected int | tileGridYOffset | The amount by which the tile grid origin should be offset
vertically from the image origin if tiling has been set,
or 0 otherwise. The initial value is 0 .
Subclasses that do not support offsetting tiles may ignore this value. |
protected boolean | canWriteProgressive | A boolean that is true if this
ImageWriteParam allows images to be written as a
progressive sequence of increasing quality passes. By default,
the value is false . Subclasses must set the value
manually.
Subclasses that do not support progressive encoding must
ensure that this value is set to |
protected int | progressiveMode | The mode controlling progressive encoding, which must be set to
one of the four MODE_* values, except
MODE_EXPLICIT . The default is
MODE_COPY_FROM_METADATA .
Subclasses that do not support progressive encoding may ignore this value. |
protected boolean | canWriteCompressed | A boolean that is true if this writer
can write images using compression. By default, the value is
false . Subclasses must set the value manually.
Subclasses that do not support compression must ensure that
this value is set to |
protected int | compressionMode | The mode controlling compression settings, which must be set to
one of the four MODE_* values. The default is
MODE_COPY_FROM_METADATA .
Subclasses that do not support compression may ignore this value. |
protected String[] | compressionTypes | An array of String s containing the names of the
available compression types. Subclasses must set the value
manually.
Subclasses that do not support compression may ignore this value. |
protected String | compressionType | A String containing the name of the current
compression type, or null if none is set.
Subclasses that do not support compression may ignore this value. |
protected float | compressionQuality | A float containing the current compression quality
setting. The initial value is 1.0F .
Subclasses that do not support compression may ignore this value. |
protected Locale | locale | A Locale to be used to localize compression type
names and quality descriptions, or null to use a
default Locale . Subclasses must set the value
manually. |
Constructor: |
---|
ImageWriteParam . It is up to
the subclass to set up the instance variables properly. |
ImageWriteParam set to use a
given Locale .
|
Methods from java.lang.Object: |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method from javax.imageio.ImageWriteParam Detail: |
---|
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. |
true if this writer supports compression. |
true if the writer can write out images
as a series of passes of progressively increasing quality. |
true if the writer can perform tiling
while writing. If this method returns false , then
setTiling will throw an
UnsupportedOperationException . |
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 The default implementation checks that compression is
supported and the compression mode is
|
|
If there are multiple compression types but none has been
set, an The default implementation checks that compression is
supported and that the compression mode is
|
String s 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 If no descriptions are available, The descriptions should be localized for the
If there are multiple compression types but none has been set,
an The default implementation checks that compression is
supported and that the compression mode is
|
float s 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, If there are multiple compression types but none has been set,
an The default implementation checks that compression is
supported and that the compression mode is
|
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
|
String s, 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
|
Locale , or
null if only a default Locale is
supported. |
Locale returned by
getLocale .
The default implementation checks whether compression is
supported and the compression mode is
|
Dimension s 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
If no array is specified on the constructor, but tiling is
allowed, then this method returns |
|
IllegalStateException is thrown. |
IllegalStateException is thrown. |
IllegalStateException is thrown. |
IllegalStateException is thrown. |
UnsupportedOperationException . |
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 The default implementation checks whether compression is
supported and the compression mode is
|
mode
argument must be one of the four modes, interpreted as follows:
The default is |
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 The default implementation checks that compression is
supported, and that the compression mode is
|
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
|
UnsupportedOperationException will
be thrown.
The mode argument determines how
the progression parameters are chosen, and must be either
The modes are interpreted as follows: The default is |
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 |
|
The default implementation sets the instance variable
|
setTiling .
The default implementation sets the instance variables
|