ImageReader.
An image encoded as part of a file or stream may be thought of
extending out in multiple dimensions: the spatial dimensions of
width and height, a number of bands, and a number of progressive
decoding passes. This class allows a contiguous (hyper)rectangular
subarea of the image in all of these dimensions to be selected for
decoding. Additionally, the spatial dimensions may be subsampled
discontinuously. Finally, color and format conversions may be
specified by controlling the ColorModel and
SampleModel of the destination image, either by
providing a BufferedImage or by using an
ImageTypeSpecifier.
An ImageReadParam object is used to specify how an
image, or a set of images, will be converted on input from
a stream in the context of the Java Image I/O framework. A plug-in for a
specific image format will return instances of
ImageReadParam from the
getDefaultReadParam method of its
ImageReader implementation.
The state maintained by an instance of
ImageReadParam is independent of any particular image
being decoded. When actual decoding takes place, the values set in
the read param are combined with the actual properties of the image
being decoded from the stream and the destination
BufferedImage that will receive the decoded pixel
data. For example, the source region set using
setSourceRegion will first be intersected with the
actual valid source area. The result will be translated by the
value returned by getDestinationOffset, and the
resulting rectangle intersected with the actual valid destination
area to yield the destination area that will be written.
The parameters specified by an ImageReadParam are
applied to an image as follows. First, if a rendering size has
been set by setSourceRenderSize, the entire decoded
image is rendered at the size given by
getSourceRenderSize. Otherwise, the image has its
natural size given by ImageReader.getWidth and
ImageReader.getHeight.
Next, the image is clipped against the source region
specified by getSourceXOffset, getSourceYOffset,
getSourceWidth, and getSourceHeight.
The resulting region is then subsampled according to the
factors given in IIOParam.. The first pixel,
the number of pixels per row, and the number of rows all depend
on the subsampling settings.
Call the minimum X and Y coordinates of the resulting rectangle
(minX, minY), its width w
and its height h.
This rectangle is offset by
(getDestinationOffset().x,
getDestinationOffset().y) and clipped against the
destination bounds. If no destination image has been set, the
destination is defined to have a width of
getDestinationOffset().x + w, and a
height of getDestinationOffset().y + h so
that all pixels of the source region may be written to the
destination.
Pixels that land, after subsampling, within the destination
image, and that are written in one of the progressive passes
specified by getSourceMinProgressivePass and
getSourceNumProgressivePasses are passed along to the
next step.
Finally, the source samples of each pixel are mapped into
destination bands according to the algorithm described in the
comment for setDestinationBands.
Plug-in writers may extend the functionality of
ImageReadParam 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. Readers will silently ignore any extended features of an
ImageReadParam subclass of which they are not aware.
Also, they may ignore any optional features that they normally
disable when creating their own ImageReadParam
instances via getDefaultReadParam.
Note that unless a query method exists for a capability, it must
be supported by all ImageReader implementations
(e.g. source render size is optional, but subsampling must be
supported).
ImageReader, ImageWriter, ImageWriteParam
| Modifier and Type | Field and Description |
|---|---|
| protected boolean | canSetSourceRenderSize
|
| protected BufferedImage | destination
The current destination |
| protected int[] | destinationBands
The set of destination bands to be used, as an array of
|
| protected int | minProgressivePass
The minimum index of a progressive pass to read from the source. |
| protected int | numProgressivePasses
The maximum number of progressive passes to read from the source. |
| protected Dimension | sourceRenderSize
The desired rendering width and height of the source, if
|
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | Returns: true if setting source rendering size is
supported.Returns |
| public BufferedImage | Returns: the BufferedImage to be written to.Returns the |
| public int[] | Returns: the indices of the destination bands to be used, ornull.Returns the set of band indices where data will be placed. |
| public int | Returns: the index of the last pass to be read, orInteger.MAX_VALUE.If |
| public int | Returns: the index of the first pass that will be decoded.Returns the index of the first progressive pass that will be decoded. |
| public int | Returns: the number of the passes that will be decoded.Returns the number of the progressive passes that will be decoded. |
| public Dimension | Returns: the rendered width and height of the source image as aDimension.Returns the width and height of the source image as it
will be rendered during decoding, if they have been set via the
|
| public void | setDestination(BufferedImage
the BufferedImage to be written to, or
destination)null.Supplies a |
| public void | setDestinationBands(int[]
an array of integer band indices to be
used. destinationBands)Sets the indices of the destination bands where data will be placed. |
| public void | setDestinationType(ImageTypeSpecifier destinationType)
Overrides javax. Sets the desired image type for the destination image, using an
|
| public void | setSourceProgressivePasses(int
the index of the first pass to be decoded. minPass, int the maximum number of passes to be decoded. numPasses)Sets the range of progressive passes that will be decoded. |
| public void | setSourceRenderSize(Dimension
a size)Dimension indicating the desired
width and height.If the image is able to be rendered at an arbitrary size, sets the source width and height to the supplied values. |
| canSetSourceRenderSize | back to summary |
|---|---|
| protected boolean canSetSourceRenderSize
| |
| destination | back to summary |
|---|---|
| protected BufferedImage destination The current destination | |
| destinationBands | back to summary |
|---|---|
| protected int[] destinationBands The set of destination bands to be used, as an array of
| |
| minProgressivePass | back to summary |
|---|---|
| protected int minProgressivePass The minimum index of a progressive pass to read from the source. By default, the value is set to 0, which indicates that passes starting with the first available pass should be decoded. Subclasses should ensure that this value is non-negative. | |
| numProgressivePasses | back to summary |
|---|---|
| protected int numProgressivePasses The maximum number of progressive passes to read from the
source. By default, the value is set to
Subclasses should ensure that this value is positive.
Additionally, if the value is not
| |
| sourceRenderSize | back to summary |
|---|---|
| protected Dimension sourceRenderSize The desired rendering width and height of the source, if
| |
| ImageReadParam | back to summary |
|---|---|
| public ImageReadParam() Constructs an | |
| canSetSourceRenderSize | back to summary |
|---|---|
| public boolean canSetSourceRenderSize() Returns
| |
| getDestination | back to summary |
|---|---|
| public BufferedImage getDestination() Returns the
| |
| getDestinationBands | back to summary |
|---|---|
| public int[] getDestinationBands() Returns the set of band indices where data will be placed.
If no value has been set,
| |
| getSourceMaxProgressivePass | back to summary |
|---|---|
| public int getSourceMaxProgressivePass() If
| |
| getSourceMinProgressivePass | back to summary |
|---|---|
| public int getSourceMinProgressivePass() Returns the index of the first progressive pass that will be decoded. If no value has been set, 0 will be returned (which is the correct value).
| |
| getSourceNumProgressivePasses | back to summary |
|---|---|
| public int getSourceNumProgressivePasses() Returns the number of the progressive passes that will be
decoded. If no value has been set,
| |
| getSourceRenderSize | back to summary |
|---|---|
| public Dimension getSourceRenderSize() Returns the width and height of the source image as it
will be rendered during decoding, if they have been set via the
| |
| setDestination | back to summary |
|---|---|
| public void setDestination(BufferedImage destination) Supplies a Pixel data from the aforementioned methods will be written
starting at the offset specified by
If At the time of reading, the image is checked to verify that
its
| |
| setDestinationBands | back to summary |
|---|---|
| public void setDestinationBands(int[] destinationBands) Sets the indices of the destination bands where data will be placed. Duplicate indices are not allowed. A Choosing a destination band subset will not affect the
number of bands in the output image of a read if no destination
image is specified; the created destination image will still
have the same number of bands as if this method had never been
called. If a different number of bands in the destination
image is desired, an image must be supplied using the
At the time of reading or writing, an
| |
| setDestinationType | back to summary |
|---|---|
| public void setDestinationType(ImageTypeSpecifier destinationType) Overrides javax. Doc from javax. Sets the desired image type for the destination image, using an
When reading, if the layout of the destination has been set
using this method, each call to an When writing, the destination type maybe used to determine
the color type of the image. The | |
| setSourceProgressivePasses | back to summary |
|---|---|
| public void setSourceProgressivePasses(int minPass, int numPasses) Sets the range of progressive passes that will be decoded. Passes outside of this range will be ignored. A progressive pass is a re-encoding of the entire image, generally at progressively higher effective resolutions, but requiring greater transmission bandwidth. The most common use of progressive encoding is found in the JPEG format, where successive passes include more detailed representations of the high-frequency image content. The actual number of passes to be decoded is determined
during decoding, based on the number of actual passes available
in the stream. Thus if A value of There is no
| |
| setSourceRenderSize | back to summary |
|---|---|
| public void setSourceRenderSize(Dimension size) throws UnsupportedOperationException If the image is able to be rendered at an arbitrary size, sets
the source width and height to the supplied values. Note that
the values returned from the Typically, the width and height should be chosen such that
the ratio of width to height closely approximates the aspect
ratio of the image, as returned from
If this plug-in does not allow the rendering size to be
set, an To remove the render size setting, pass in a value of
| |