jdk/src/share/classes/javax/imageio/ImageReadParam.java
author prr
Tue, 06 Aug 2013 17:11:29 -0700
changeset 19168 ff364494f2b8
parent 5506 202f599c92aa
child 22584 eed64ee05369
permissions -rw-r--r--
8022455: Fix doclint warnings in javax.imageio Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.imageio;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.Dimension;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.image.BufferedImage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * A class describing how a stream is to be decoded.  Instances of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * this class or its subclasses are used to supply prescriptive
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * "how-to" information to instances of <code>ImageReader</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * <p> An image encoded as part of a file or stream may be thought of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * extending out in multiple dimensions: the spatial dimensions of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * width and height, a number of bands, and a number of progressive
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * decoding passes.  This class allows a contiguous (hyper)rectangular
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * subarea of the image in all of these dimensions to be selected for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * decoding.  Additionally, the spatial dimensions may be subsampled
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * discontinuously.  Finally, color and format conversions may be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * specified by controlling the <code>ColorModel</code> and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * <code>SampleModel</code> of the destination image, either by
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * providing a <code>BufferedImage</code> or by using an
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * <code>ImageTypeSpecifier</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * <p> An <code>ImageReadParam</code> object is used to specify how an
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * image, or a set of images, will be converted on input from
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * a stream in the context of the Java Image I/O framework.  A plug-in for a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * specific image format will return instances of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * <code>ImageReadParam</code> from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * <code>getDefaultReadParam</code> method of its
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * <code>ImageReader</code> implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * <p> The state maintained by an instance of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * <code>ImageReadParam</code> is independent of any particular image
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * being decoded.  When actual decoding takes place, the values set in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * the read param are combined with the actual properties of the image
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * being decoded from the stream and the destination
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * <code>BufferedImage</code> that will receive the decoded pixel
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * data.  For example, the source region set using
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * <code>setSourceRegion</code> will first be intersected with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * actual valid source area.  The result will be translated by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * value returned by <code>getDestinationOffset</code>, and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * resulting rectangle intersected with the actual valid destination
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * area to yield the destination area that will be written.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * <p> The parameters specified by an <code>ImageReadParam</code> are
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * applied to an image as follows.  First, if a rendering size has
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * been set by <code>setSourceRenderSize</code>, the entire decoded
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * image is rendered at the size given by
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * <code>getSourceRenderSize</code>.  Otherwise, the image has its
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * natural size given by <code>ImageReader.getWidth</code> and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * <code>ImageReader.getHeight</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * <p> Next, the image is clipped against the source region
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * specified by <code>getSourceXOffset</code>, <code>getSourceYOffset</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * <code>getSourceWidth</code>, and <code>getSourceHeight</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 * <p> The resulting region is then subsampled according to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 * factors given in {@link IIOParam#setSourceSubsampling
19168
ff364494f2b8 8022455: Fix doclint warnings in javax.imageio
prr
parents: 5506
diff changeset
    83
 * IIOParam.setSourceSubsampling}.  The first pixel,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 * the number of pixels per row, and the number of rows all depend
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 * on the subsampling settings.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 * Call the minimum X and Y coordinates of the resulting rectangle
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 * (<code>minX</code>, <code>minY</code>), its width <code>w</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 * and its height <code>h</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 * <p> This rectangle is offset by
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 * (<code>getDestinationOffset().x</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 * <code>getDestinationOffset().y</code>) and clipped against the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 * destination bounds.  If no destination image has been set, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 * destination is defined to have a width of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 * <code>getDestinationOffset().x</code> + <code>w</code>, and a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
 * height of <code>getDestinationOffset().y</code> + <code>h</code> so
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
 * that all pixels of the source region may be written to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
 * destination.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
 * <p> Pixels that land, after subsampling, within the destination
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
 * image, and that are written in one of the progressive passes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
 * specified by <code>getSourceMinProgressivePass</code> and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
 * <code>getSourceNumProgressivePasses</code> are passed along to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
 * next step.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
 * <p> Finally, the source samples of each pixel are mapped into
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
 * destination bands according to the algorithm described in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
 * comment for <code>setDestinationBands</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
 * <p> Plug-in writers may extend the functionality of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
 * <code>ImageReadParam</code> by providing a subclass that implements
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
 * additional, plug-in specific interfaces.  It is up to the plug-in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
 * to document what interfaces are available and how they are to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
 * used.  Readers will silently ignore any extended features of an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
 * <code>ImageReadParam</code> subclass of which they are not aware.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
 * Also, they may ignore any optional features that they normally
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
 * disable when creating their own <code>ImageReadParam</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
 * instances via <code>getDefaultReadParam</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
 * <p> Note that unless a query method exists for a capability, it must
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
 * be supported by all <code>ImageReader</code> implementations
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
 * (<i>e.g.</i> source render size is optional, but subsampling must be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
 * supported).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
 * @see ImageReader
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
 * @see ImageWriter
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
 * @see ImageWriteParam
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
public class ImageReadParam extends IIOParam {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * <code>true</code> if this <code>ImageReadParam</code> allows
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * the source rendering dimensions to be set.  By default, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * value is <code>false</code>.  Subclasses must set this value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * manually.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * <p> <code>ImageReader</code>s that do not support setting of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * the source render size should set this value to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * <code>false</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    protected boolean canSetSourceRenderSize = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * The desired rendering width and height of the source, if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * <code>canSetSourceRenderSize</code> is <code>true</code>, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * <p> <code>ImageReader</code>s that do not support setting of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * the source render size may ignore this value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    protected Dimension sourceRenderSize = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * The current destination <code>BufferedImage</code>, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * <code>null</code> if none has been set.  By default, the value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * is <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    protected BufferedImage destination = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * The set of destination bands to be used, as an array of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * <code>int</code>s.  By default, the value is <code>null</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * indicating all destination bands should be written in order.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    protected int[] destinationBands = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * The minimum index of a progressive pass to read from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * source.  By default, the value is set to 0, which indicates
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * that passes starting with the first available pass should be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * decoded.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * <p> Subclasses should ensure that this value is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * non-negative.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    protected int minProgressivePass = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * The maximum number of progressive passes to read from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * source.  By default, the value is set to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * <code>Integer.MAX_VALUE</code>, which indicates that passes up
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * to and including the last available pass should be decoded.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * <p> Subclasses should ensure that this value is positive.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * Additionally, if the value is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * <code>Integer.MAX_VALUE</code>, then <code>minProgressivePass +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * numProgressivePasses - 1</code> should not exceed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * <code>Integer.MAX_VALUE</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    protected int numProgressivePasses = Integer.MAX_VALUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * Constructs an <code>ImageReadParam</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    public ImageReadParam() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    // Comment inherited
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    public void setDestinationType(ImageTypeSpecifier destinationType) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        super.setDestinationType(destinationType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        setDestination(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * Supplies a <code>BufferedImage</code> to be used as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * destination for decoded pixel data.  The currently set image
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * will be written to by the <code>read</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * <code>readAll</code>, and <code>readRaster</code> methods, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * a reference to it will be returned by those methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * <p> Pixel data from the aforementioned methods will be written
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * starting at the offset specified by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * <code>getDestinationOffset</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * <p> If <code>destination</code> is <code>null</code>, a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * newly-created <code>BufferedImage</code> will be returned by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * those methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * <p> At the time of reading, the image is checked to verify that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * its <code>ColorModel</code> and <code>SampleModel</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * correspond to one of the <code>ImageTypeSpecifier</code>s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * returned from the <code>ImageReader</code>'s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * <code>getImageTypes</code> method.  If it does not, the reader
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * will throw an <code>IIOException</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     * @param destination the BufferedImage to be written to, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * @see #getDestination
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    public void setDestination(BufferedImage destination) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        this.destination = destination;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     * Returns the <code>BufferedImage</code> currently set by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     * <code>setDestination</code> method, or <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     * if none is set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * @return the BufferedImage to be written to.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     * @see #setDestination
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    public BufferedImage getDestination() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        return destination;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     * Sets the indices of the destination bands where data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     * will be placed.  Duplicate indices are not allowed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     * <p> A <code>null</code> value indicates that all destination
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     * bands will be used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     * <p> Choosing a destination band subset will not affect the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * number of bands in the output image of a read if no destination
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * image is specified; the created destination image will still
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     * have the same number of bands as if this method had never been
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * called.  If a different number of bands in the destination
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     * image is desired, an image must be supplied using the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * <code>ImageReadParam.setDestination</code> method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     * <p> At the time of reading or writing, an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     * <code>IllegalArgumentException</code> will be thrown by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     * reader or writer if a value larger than the largest destination
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * band index has been specified, or if the number of source bands
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * and destination bands to be used differ.  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     * <code>ImageReader.checkReadParamBandSettings</code> method may
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * be used to automate this test.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * @param destinationBands an array of integer band indices to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     * used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     * @exception IllegalArgumentException if <code>destinationBands</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     * contains a negative or duplicate value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     * @see #getDestinationBands
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     * @see #getSourceBands
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     * @see ImageReader#checkReadParamBandSettings
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    public void setDestinationBands(int[] destinationBands) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        if (destinationBands == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
            this.destinationBands = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
            int numBands = destinationBands.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
            for (int i = 0; i < numBands; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
                int band = destinationBands[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
                if (band < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
                    throw new IllegalArgumentException("Band value < 0!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
                for (int j = i + 1; j < numBands; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
                    if (band == destinationBands[j]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
                        throw new IllegalArgumentException("Duplicate band value!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
            this.destinationBands = (int[])destinationBands.clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     * Returns the set of band indices where data will be placed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     * If no value has been set, <code>null</code> is returned to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     * indicate that all destination bands will be used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     * @return the indices of the destination bands to be used,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     * or <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     * @see #setDestinationBands
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    public int[] getDestinationBands() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
        if (destinationBands == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
            return (int[])(destinationBands.clone());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     * Returns <code>true</code> if this reader allows the source
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     * image to be rendered at an arbitrary size as part of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     * decoding process, by means of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     * <code>setSourceRenderSize</code> method.  If this method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     * returns <code>false</code>, calls to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * <code>setSourceRenderSize</code> will throw an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     * <code>UnsupportedOperationException</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     * @return <code>true</code> if setting source rendering size is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     * supported.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     * @see #setSourceRenderSize
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
    public boolean canSetSourceRenderSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
        return canSetSourceRenderSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     * If the image is able to be rendered at an arbitrary size, sets
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     * the source width and height to the supplied values.  Note that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     * the values returned from the <code>getWidth</code> and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     * <code>getHeight</code> methods on <code>ImageReader</code> are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     * not affected by this method; they will continue to return the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     * default size for the image.  Similarly, if the image is also
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     * tiled the tile width and height are given in terms of the default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     * size.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
     * <p> Typically, the width and height should be chosen such that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     * the ratio of width to height closely approximates the aspect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     * ratio of the image, as returned from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     * <code>ImageReader.getAspectRatio</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     * <p> If this plug-in does not allow the rendering size to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     * set, an <code>UnsupportedOperationException</code> will be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     * thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     * <p> To remove the render size setting, pass in a value of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     * <code>null</code> for <code>size</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     * @param size a <code>Dimension</code> indicating the desired
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     * width and height.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
     * @exception IllegalArgumentException if either the width or the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     * height is negative or 0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     * @exception UnsupportedOperationException if image resizing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
     * is not supported by this plug-in.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     * @see #getSourceRenderSize
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
     * @see ImageReader#getWidth
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
     * @see ImageReader#getHeight
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     * @see ImageReader#getAspectRatio
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
    public void setSourceRenderSize(Dimension size)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
        throws UnsupportedOperationException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
        if (!canSetSourceRenderSize()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
            throw new UnsupportedOperationException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
                ("Can't set source render size!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
        if (size == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
            this.sourceRenderSize = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
            if (size.width <= 0 || size.height <= 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
                throw new IllegalArgumentException("width or height <= 0!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
            this.sourceRenderSize = (Dimension)size.clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
     * Returns the width and height of the source image as it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     * will be rendered during decoding, if they have been set via the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
     * <code>setSourceRenderSize</code> method.  A
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     * <code>null</code>value indicates that no setting has been made.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     * @return the rendered width and height of the source image
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     * as a <code>Dimension</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     * @see #setSourceRenderSize
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
    public Dimension getSourceRenderSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
        return (sourceRenderSize == null) ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
            null : (Dimension)sourceRenderSize.clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
     * Sets the range of progressive passes that will be decoded.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
     * Passes outside of this range will be ignored.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
     * <p> A progressive pass is a re-encoding of the entire image,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
     * generally at progressively higher effective resolutions, but
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
     * requiring greater transmission bandwidth.  The most common use
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     * of progressive encoding is found in the JPEG format, where
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     * successive passes include more detailed representations of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     * high-frequency image content.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
     * <p> The actual number of passes to be decoded is determined
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
     * during decoding, based on the number of actual passes available
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
     * in the stream.  Thus if <code>minPass + numPasses - 1</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
     * larger than the index of the last available passes, decoding
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
     * will end with that pass.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
     * <p> A value of <code>numPasses</code> of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
     * <code>Integer.MAX_VALUE</code> indicates that all passes from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
     * <code>minPass</code> forward should be read.  Otherwise, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
     * index of the last pass (<i>i.e.</i>, <code>minPass + numPasses
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
     * - 1</code>) must not exceed <code>Integer.MAX_VALUE</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     * <p> There is no <code>unsetSourceProgressivePasses</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
     * method; the same effect may be obtained by calling
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     * <code>setSourceProgressivePasses(0, Integer.MAX_VALUE)</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     * @param minPass the index of the first pass to be decoded.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
     * @param numPasses the maximum number of passes to be decoded.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
     * @exception IllegalArgumentException if <code>minPass</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
     * negative, <code>numPasses</code> is negative or 0, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
     * <code>numPasses</code> is smaller than
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
     * <code>Integer.MAX_VALUE</code> but <code>minPass +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
     * numPasses - 1</code> is greater than
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
     * <code>INTEGER.MAX_VALUE</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
     * @see #getSourceMinProgressivePass
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
     * @see #getSourceMaxProgressivePass
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
    public void setSourceProgressivePasses(int minPass, int numPasses) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
        if (minPass < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
            throw new IllegalArgumentException("minPass < 0!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
        if (numPasses <= 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
            throw new IllegalArgumentException("numPasses <= 0!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
        if ((numPasses != Integer.MAX_VALUE) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
            (((minPass + numPasses - 1) & 0x80000000) != 0)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
            throw new IllegalArgumentException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
                ("minPass + numPasses - 1 > INTEGER.MAX_VALUE!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
        this.minProgressivePass = minPass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
        this.numProgressivePasses = numPasses;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
     * Returns the index of the first progressive pass that will be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
     * decoded. If no value has been set, 0 will be returned (which is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
     * the correct value).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
     * @return the index of the first pass that will be decoded.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
     * @see #setSourceProgressivePasses
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
     * @see #getSourceNumProgressivePasses
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
    public int getSourceMinProgressivePass() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
        return minProgressivePass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
     * If <code>getSourceNumProgressivePasses</code> is equal to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
     * <code>Integer.MAX_VALUE</code>, returns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
     * <code>Integer.MAX_VALUE</code>.  Otherwise, returns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
     * <code>getSourceMinProgressivePass() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
     * getSourceNumProgressivePasses() - 1</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
     * @return the index of the last pass to be read, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
     * <code>Integer.MAX_VALUE</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
    public int getSourceMaxProgressivePass() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
        if (numProgressivePasses == Integer.MAX_VALUE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
            return Integer.MAX_VALUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
            return minProgressivePass + numProgressivePasses - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
     * Returns the number of the progressive passes that will be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
     * decoded. If no value has been set,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
     * <code>Integer.MAX_VALUE</code> will be returned (which is the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
     * correct value).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
     * @return the number of the passes that will be decoded.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
     * @see #setSourceProgressivePasses
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
     * @see #getSourceMinProgressivePass
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
    public int getSourceNumProgressivePasses() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
        return numProgressivePasses;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
}