2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 * @author Sergey I. Salishev
19 * @version $Revision: 1.2 $
22 package javax.imageio;
24 import java.awt.Dimension;
25 import java.awt.image.BufferedImage;
28 * @author Sergey I. Salishev
29 * @version $Revision: 1.2 $
33 * The ImageReadParam class provides information to the ImageReader about how an
34 * image is to be decoded.
38 public class ImageReadParam extends IIOParam {
41 * This flag indicates if this ImageReadParam supports setting the source
44 protected boolean canSetSourceRenderSize;
47 * The destination BufferedImage.
49 protected BufferedImage destination;
52 * The destination bands.
54 protected int[] destinationBands;
57 * The minimum progressive pass.
59 protected int minProgressivePass;
62 * The number of progressive passes.
64 protected int numProgressivePasses;
67 * The source render size.
69 protected Dimension sourceRenderSize;
72 * Returns true if this ImageReaderParam supports rendering a source image
73 * at an arbitrary size.
75 * @return true, if this ImageReaderParam supports rendering a source image
76 * at an arbitrary size, false otherwise.
78 public boolean canSetSourceRenderSize() {
79 return canSetSourceRenderSize;
83 * Gets the current destination image as BufferedImage.
85 * @return the BufferedImage which represents the destination.
87 public BufferedImage getDestination() {
92 * Gets the indices of destination bands.
94 * @return the array of destination bands.
96 public int[] getDestinationBands() {
97 return destinationBands;
101 * Gets the index of the maximum pass to be decoded. This method returns
102 * Integer.MAX_VALUE, if getSourceNumProgressivePasses() method returns
103 * value that is equal to Integer.MAX_VALUE. Otherwise this method returns
104 * getSourceMinProgressivePass() + getSourceNumProgressivePasses() - 1.
106 * @return the index of the maximum pass to be decoded.
108 public int getSourceMaxProgressivePass() {
109 if (getSourceNumProgressivePasses() == Integer.MAX_VALUE) {
110 return Integer.MAX_VALUE;
112 return getSourceMinProgressivePass() + getSourceNumProgressivePasses() - 1;
116 * Gets the index of the minimum progressive pass that is decoded, default
119 * @return the index of the minimum progressive pass that is decoded,
122 public int getSourceMinProgressivePass() {
123 return minProgressivePass;
127 * Gets the number of progressive passes. The default value is
130 * @return the number of progressive passes.
132 public int getSourceNumProgressivePasses() {
133 return numProgressivePasses;
137 * Gets the dimension of source image which will be rendered during decoding
140 * @return the source render size.
142 public Dimension getSourceRenderSize() {
143 return sourceRenderSize;
147 * Sets the specified destination image. This image will be used by read,
148 * readAll, and readRaster methods, and a reference to it will be returned
152 * the destination image.
154 public void setDestination(BufferedImage destination) {
155 this.destination = destination;
159 * Sets the indices of the destination bands.
161 * @param destinationBands
162 * the indices of the destination bands.
164 public void setDestinationBands(int[] destinationBands) {
165 this.destinationBands = destinationBands;
169 public void setDestinationType(ImageTypeSpecifier destinationType) {
170 this.destinationType = destinationType;
174 * Sets the source progressive passes.
177 * the index of the minimum pass to be decoded.
179 * the number of passes to be decoded.
181 public void setSourceProgressivePasses(int minPass, int numPasses) {
182 minProgressivePass = minPass;
183 numProgressivePasses = numPasses;
187 * Sets the dimension size of source image if an image can be rendered at an
191 * the size of rendered image.
192 * @throws UnsupportedOperationException
193 * the unsupported operation exception.
195 public void setSourceRenderSize(Dimension size) throws UnsupportedOperationException {
196 if (!canSetSourceRenderSize) {
197 throw new UnsupportedOperationException("can't set source renderer size");
199 sourceRenderSize = size;