2008-10-21 14:00:00 +00:00
|
|
|
/*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership.
|
|
|
|
* The ASF licenses this file to You under the Apache License, Version 2.0
|
|
|
|
* (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* @author Sergey I. Salishev
|
|
|
|
* @version $Revision: 1.2 $
|
|
|
|
*/
|
2008-12-18 02:05:43 +00:00
|
|
|
|
2008-10-21 14:00:00 +00:00
|
|
|
package javax.imageio;
|
|
|
|
|
|
|
|
import java.awt.Dimension;
|
|
|
|
import java.awt.image.BufferedImage;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @author Sergey I. Salishev
|
|
|
|
* @version $Revision: 1.2 $
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2008-12-18 02:05:43 +00:00
|
|
|
* The ImageReadParam class provides information to the ImageReader about how an
|
|
|
|
* image is to be decoded.
|
|
|
|
*
|
|
|
|
* @since Android 1.0
|
2008-10-21 14:00:00 +00:00
|
|
|
*/
|
|
|
|
public class ImageReadParam extends IIOParam {
|
|
|
|
|
2008-12-18 02:05:43 +00:00
|
|
|
/**
|
|
|
|
* This flag indicates if this ImageReadParam supports setting the source
|
|
|
|
* rendering size.
|
2008-10-21 14:00:00 +00:00
|
|
|
*/
|
|
|
|
protected boolean canSetSourceRenderSize;
|
2008-12-18 02:05:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The destination BufferedImage.
|
2008-10-21 14:00:00 +00:00
|
|
|
*/
|
|
|
|
protected BufferedImage destination;
|
2008-12-18 02:05:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The destination bands.
|
|
|
|
*/
|
2008-10-21 14:00:00 +00:00
|
|
|
protected int[] destinationBands;
|
2008-12-18 02:05:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The minimum progressive pass.
|
2008-10-21 14:00:00 +00:00
|
|
|
*/
|
|
|
|
protected int minProgressivePass;
|
2008-12-18 02:05:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The number of progressive passes.
|
2008-10-21 14:00:00 +00:00
|
|
|
*/
|
|
|
|
protected int numProgressivePasses;
|
2008-12-18 02:05:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The source render size.
|
|
|
|
*/
|
2008-10-21 14:00:00 +00:00
|
|
|
protected Dimension sourceRenderSize;
|
|
|
|
|
|
|
|
/**
|
2008-12-18 02:05:43 +00:00
|
|
|
* Returns true if this ImageReaderParam supports rendering a source image
|
|
|
|
* at an arbitrary size.
|
2008-10-21 14:00:00 +00:00
|
|
|
*
|
2008-12-18 02:05:43 +00:00
|
|
|
* @return true, if this ImageReaderParam supports rendering a source image
|
|
|
|
* at an arbitrary size, false otherwise.
|
2008-10-21 14:00:00 +00:00
|
|
|
*/
|
|
|
|
public boolean canSetSourceRenderSize() {
|
|
|
|
return canSetSourceRenderSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the current destination image as BufferedImage.
|
|
|
|
*
|
|
|
|
* @return the BufferedImage which represents the destination.
|
|
|
|
*/
|
|
|
|
public BufferedImage getDestination() {
|
|
|
|
return destination;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the indices of destination bands.
|
|
|
|
*
|
|
|
|
* @return the array of destination bands.
|
|
|
|
*/
|
|
|
|
public int[] getDestinationBands() {
|
|
|
|
return destinationBands;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2008-12-18 02:05:43 +00:00
|
|
|
* Gets the index of the maximum pass to be decoded. This method returns
|
|
|
|
* Integer.MAX_VALUE, if getSourceNumProgressivePasses() method returns
|
|
|
|
* value that is equal to Integer.MAX_VALUE. Otherwise this method returns
|
2008-10-21 14:00:00 +00:00
|
|
|
* getSourceMinProgressivePass() + getSourceNumProgressivePasses() - 1.
|
|
|
|
*
|
|
|
|
* @return the index of the maximum pass to be decoded.
|
|
|
|
*/
|
|
|
|
public int getSourceMaxProgressivePass() {
|
|
|
|
if (getSourceNumProgressivePasses() == Integer.MAX_VALUE) {
|
|
|
|
return Integer.MAX_VALUE;
|
|
|
|
}
|
|
|
|
return getSourceMinProgressivePass() + getSourceNumProgressivePasses() - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2008-12-18 02:05:43 +00:00
|
|
|
* Gets the index of the minimum progressive pass that is decoded, default
|
|
|
|
* is 0.
|
2008-10-21 14:00:00 +00:00
|
|
|
*
|
|
|
|
* @return the index of the minimum progressive pass that is decoded,
|
2008-12-18 02:05:43 +00:00
|
|
|
* default is 0.
|
2008-10-21 14:00:00 +00:00
|
|
|
*/
|
|
|
|
public int getSourceMinProgressivePass() {
|
|
|
|
return minProgressivePass;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2008-12-18 02:05:43 +00:00
|
|
|
* Gets the number of progressive passes. The default value is
|
|
|
|
* Integer.MAX_VALUE.
|
2008-10-21 14:00:00 +00:00
|
|
|
*
|
|
|
|
* @return the number of progressive passes.
|
|
|
|
*/
|
|
|
|
public int getSourceNumProgressivePasses() {
|
|
|
|
return numProgressivePasses;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2008-12-18 02:05:43 +00:00
|
|
|
* Gets the dimension of source image which will be rendered during decoding
|
|
|
|
* process.
|
2008-10-21 14:00:00 +00:00
|
|
|
*
|
|
|
|
* @return the source render size.
|
|
|
|
*/
|
|
|
|
public Dimension getSourceRenderSize() {
|
|
|
|
return sourceRenderSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2008-12-18 02:05:43 +00:00
|
|
|
* Sets the specified destination image. This image will be used by read,
|
|
|
|
* readAll, and readRaster methods, and a reference to it will be returned
|
|
|
|
* by those methods.
|
2008-10-21 14:00:00 +00:00
|
|
|
*
|
2008-12-18 02:05:43 +00:00
|
|
|
* @param destination
|
|
|
|
* the destination image.
|
2008-10-21 14:00:00 +00:00
|
|
|
*/
|
|
|
|
public void setDestination(BufferedImage destination) {
|
|
|
|
this.destination = destination;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the indices of the destination bands.
|
|
|
|
*
|
2008-12-18 02:05:43 +00:00
|
|
|
* @param destinationBands
|
|
|
|
* the indices of the destination bands.
|
2008-10-21 14:00:00 +00:00
|
|
|
*/
|
|
|
|
public void setDestinationBands(int[] destinationBands) {
|
|
|
|
this.destinationBands = destinationBands;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setDestinationType(ImageTypeSpecifier destinationType) {
|
|
|
|
this.destinationType = destinationType;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the source progressive passes.
|
|
|
|
*
|
2008-12-18 02:05:43 +00:00
|
|
|
* @param minPass
|
|
|
|
* the index of the minimum pass to be decoded.
|
|
|
|
* @param numPasses
|
|
|
|
* the number of passes to be decoded.
|
2008-10-21 14:00:00 +00:00
|
|
|
*/
|
|
|
|
public void setSourceProgressivePasses(int minPass, int numPasses) {
|
|
|
|
minProgressivePass = minPass;
|
|
|
|
numProgressivePasses = numPasses;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2008-12-18 02:05:43 +00:00
|
|
|
* Sets the dimension size of source image if an image can be rendered at an
|
|
|
|
* arbitrary size.
|
2008-10-21 14:00:00 +00:00
|
|
|
*
|
2008-12-18 02:05:43 +00:00
|
|
|
* @param size
|
|
|
|
* the size of rendered image.
|
|
|
|
* @throws UnsupportedOperationException
|
|
|
|
* the unsupported operation exception.
|
2008-10-21 14:00:00 +00:00
|
|
|
*/
|
|
|
|
public void setSourceRenderSize(Dimension size) throws UnsupportedOperationException {
|
|
|
|
if (!canSetSourceRenderSize) {
|
|
|
|
throw new UnsupportedOperationException("can't set source renderer size");
|
|
|
|
}
|
2008-12-18 02:05:43 +00:00
|
|
|
sourceRenderSize = size;
|
2008-10-21 14:00:00 +00:00
|
|
|
}
|
|
|
|
}
|