public class ImageReadParam extends IIOParam
ImageReader 。 
        编码为文件或流的一部分的图像可以被认为在多个维度上延伸:宽度和高度的空间维度,频带的数量以及逐行解码通路的数量。 该类允许选择所有这些维度中的图像的连续(超)矩形子区域进行解码。 此外,空间维度可以不连续地二次采样。 最后,可以通过使用BufferedImage或使用ImageTypeSpecifier控制目标图像的ColorModel和SampleModel来指定颜色和格式ImageTypeSpecifier 。 
 ImageReadParam对象用于指定如何在Java Image I / O框架的上下文中从流中输入的图像或一组图像进行转换。 用于特定图像格式的ImageReadParam将从其ImageReader实现的getDefaultReadParam方法返回ImageReadParam的实例。 
 由ImageReadParam实例ImageReadParam的状态与被解码的任何特定图像无关。 当实际解码发生时,将读取参数中设置的值与正在解码的图像的实际属性和将接收解码的像素数据的目标BufferedImage 。 例如,使用setSourceRegion设置的源区域将首先与实际的有效源区域相交。 结果将由getDestinationOffset返回的值进行getDestinationOffset ,并将所得到的矩形与实际有效目标区域相交,以产生将被写入的目标区域。 
 由ImageReadParam指定的ImageReadParam应用于图像如下。 首先,如果呈现大小,已被设置setSourceRenderSize ,整个解码图像在给出的大小来呈现getSourceRenderSize 。 否则,图像的自然尺寸由ImageReader.getWidth和ImageReader.getHeight 。 
 接下来,图像被裁剪针对由指定的源区getSourceXOffset , getSourceYOffset , getSourceWidth和getSourceHeight 。 
 然后根据IIOParam.setSourceSubsampling中给出的因素对所得区域进行二次抽样 。 第一个像素,每行的像素数以及行数都取决于子采样设置。 呼叫的最小X和所得矩形(Y坐标minX , minY ),其宽度w和其高度h 。 
 该矩形是通过(偏移getDestinationOffset().x , getDestinationOffset().y )和针对目的地边界裁剪。 如果没有设置目的地图像,目的地被定义为宽度为getDestinationOffset().x + w ,高度为getDestinationOffset().y + h ,以便可以将源区域的所有像素写入目的地。 
 在二次抽样之后,在目标图像中着陆并以getSourceMinProgressivePass和getSourceNumProgressivePasses的渐进通过之一进行getSourceMinProgressivePass getSourceNumProgressivePasses被传递到下一步。 
 最后,根据setDestinationBands的评论中setDestinationBands算法将每个像素的源样本映射到目标频带。 
 插件作家可以延伸的功能ImageReadParam通过提供实现额外的子类,插件特定的接口。 插件可以记录哪些接口可用,以及如何使用它们。 读者将默认忽略他们不知道的ImageReadParam子类的任何扩展功能。 此外,他们可能忽略通过getDefaultReadParam创建自己的ImageReadParam实例时通常禁用的任何可选功能。 
 请注意,除非存在某种功能的查询方法,否则必须由所有ImageReader支持( 例如,源渲染大小是可选的,但必须支持子抽样)。 
ImageReader , ImageWriter , ImageWriteParam 
       | Modifier and Type | Field and Description | 
|---|---|
| protected boolean | canSetSourceRenderSizetrue如果这ImageReadParam允许设置源渲染维度。 | 
| protected BufferedImage | destination
              当前目的地 
              BufferedImage或null如果没有设置。 | 
| protected int[] | destinationBands
              要使用的目标频带集合,作为 
              int的阵列。 | 
| protected int | minProgressivePass
              从源读取的逐行传递的最小索引。 
             | 
| protected int | numProgressivePasses
              从源头读取的最大次数。 
             | 
| protected Dimension | sourceRenderSize
              如果 
              canSetSourceRenderSize是true或null,则所需的渲染宽度和源的高度。 | 
controller, defaultController, destinationOffset, destinationType, sourceBands, sourceRegion, sourceXSubsampling, sourceYSubsampling, subsamplingXOffset, subsamplingYOffset| Constructor and Description | 
|---|
| ImageReadParam()
              构造一个 
              ImageReadParam。 | 
| Modifier and Type | Method and Description | 
|---|---|
| boolean | canSetSourceRenderSize()
              返回 
              true如果该读取器允许源图像以任意大小作为解码过程的一部分,通过setSourceRenderSize方法。 | 
| BufferedImage | getDestination()
              返回 
              BufferedImage目前由设置setDestination方法,或null,如果没有设置。 | 
| int[] | getDestinationBands()
              返回将放置数据的频带索引集。 
             | 
| int | getSourceMaxProgressivePass()
              如果 
              getSourceNumProgressivePasses等于Integer.MAX_VALUE,则返回Integer.MAX_VALUE。 | 
| int | getSourceMinProgressivePass()
              返回将被解码的第一个循环遍的索引。 
             | 
| int | getSourceNumProgressivePasses()
              返回将被解码的渐进道次数。 
             | 
| Dimension | getSourceRenderSize()
              如果通过 
              setSourceRenderSize方法设置,则返回源映像在解码过程中渲染时的宽度和高度。 | 
| void | setDestination(BufferedImage destination)
              提供 
              BufferedImage作为解码像素数据的目的地。 | 
| void | setDestinationBands(int[] destinationBands)
              设置要放置数据的目标频带的索引。 
             | 
| void | setDestinationType(ImageTypeSpecifier destinationType)
              使用 
              ImageTypeSpecifier设置目标图像的所需图像类型。 | 
| void | setSourceProgressivePasses(int minPass, int numPasses)
              设置将被解码的渐进道次的范围。 
             | 
| void | setSourceRenderSize(Dimension size)
              如果图像能够以任意大小呈现,请将源宽度和高度设置为提供的值。 
             | 
activateController, getController, getDefaultController, getDestinationOffset, getDestinationType, getSourceBands, getSourceRegion, getSourceXSubsampling, getSourceYSubsampling, getSubsamplingXOffset, getSubsamplingYOffset, hasController, setController, setDestinationOffset, setSourceBands, setSourceRegion, setSourceSubsamplingprotected boolean canSetSourceRenderSize
true如果这个ImageReadParam允许设置源渲染维度。 
           默认值为false 。 
           子类必须手动设置此值。 
            ImageReader s不支持设置源渲染大小应将此值设置为false 。 
protected Dimension sourceRenderSize
canSetSourceRenderSize是true或null 。 
            ImageReader s不支持设置源渲染大小可能会忽略此值。 
protected BufferedImage destination
BufferedImage或null如果没有设置。 
           默认值为null 。 
          protected int[] destinationBands
int的阵列。 
           默认值为null ,表示所有目的地频段应按顺序写入。 
          protected int minProgressivePass
子类应确保此值为非负数。
protected int numProgressivePasses
Integer.MAX_VALUE ,这表示应该解码通过并包括最后一个可用的通行证。 
            子类应确保此值为正。 另外如果值不是Integer.MAX_VALUE ,那么minProgressivePass + numProgressivePasses - 1不应超过Integer.MAX_VALUE 。 
public void setDestinationType(ImageTypeSpecifier destinationType)
IIOParam 
          ImageTypeSpecifier设置目标图像所需的图像类型。 
            读取时,如果目标的布局已经使用这种方法设置,每次调用一个ImageReader read方法将返回一个新BufferedImage使用由所提供的类型说明符所指定的格式。 作为副作用,任何由BufferedImage设置的ImageReadParam.setDestination(BufferedImage)将不再被设置为目的地。 换句话说,这种方法可以被认为是调用setDestination((BufferedImage)null) 。 
 当写入时,目的地类型可能用于确定图像的颜色类型。 SampleModel信息将被忽略,可能是null 。 例如,4带图像可以表示CMYK或RGBA数据。 如果设置了目的地类型,其ColorModel将覆盖图像本身上的任何ColorModel 。 当使用setSourceBands时,这是至关重要的,因为图像的ColorModel将引用整个图像,而不是被写入的带子集。 
setDestinationType在 
            IIOParam 
           destinationType -的 
            ImageTypeSpecifier被用来确定目标布局和颜色类型。 
           IIOParam.getDestinationType() 
           public void setDestination(BufferedImage destination)
BufferedImage作为解码像素数据的目的地。 
           当前设置的图像将被写入到read , readAll和readRaster方法,以及对它的引用将由这些方法返回。 
            在偏移通过指定从前述方法中的象素数据将被写入的起始getDestinationOffset 。 
 如果destination是null ,则通过这些方法将返回新创建的BufferedImage 。 
 在读出时,该图像被检查以验证其ColorModel和SampleModel对应的一个ImageTypeSpecifier š从返回ImageReader的getImageTypes方法。 如果没有,读者会扔一个IIOException 。 
destination - 要写入的BufferedImage,或 
            null 。 
           getDestination() 
           public BufferedImage getDestination()
BufferedImage目前由设置 
           setDestination方法,或 
           null ,如果没有设置。 
          setDestination(java.awt.image.BufferedImage) 
           public void setDestinationBands(int[] destinationBands)
 null值表示将使用所有目标频带。 
 如果没有指定目的地图像,则选择目的地频带子集不会影响读取的输出图像中的频带数; 创建的目标图像仍然具有相同数量的带,就像该方法从未被调用一样。 如果需要目标图像中的不同数量的频带,则必须使用ImageReadParam.setDestination方法提供图像。 
 在读取或写入时,一个IllegalArgumentException将由读取器或写入器被抛出如果已指定比最大目标band指数值更大的值,或者如果要使用的源频带和目的地频带的数目是不同的。 ImageReader.checkReadParamBandSettings方法可用于自动化此测试。 
destinationBands - 要使用的整数带索引数组。 
           IllegalArgumentException - 如果 
            destinationBands包含负值或重复值。 
           getDestinationBands() , 
            IIOParam.getSourceBands() , 
            ImageReader.checkReadParamBandSettings(javax.imageio.ImageReadParam, int, int) 
           public int[] getDestinationBands()
null以指示将使用所有目的地频带。 
          null 。 
           setDestinationBands(int[]) 
           public boolean canSetSourceRenderSize()
true如果该读取器允许源图像以任意大小作为解码过程的一部分,通过setSourceRenderSize方法。 
           如果这个方法返回false ,调用setSourceRenderSize会抛出一个UnsupportedOperationException 。 
          true如果设置源渲染大小被支持。 
           setSourceRenderSize(java.awt.Dimension) 
           public void setSourceRenderSize(Dimension size) throws UnsupportedOperationException
getWidth和getHeight方法在ImageReader上返回的值不受此方法的影响; 
           他们将继续返回图像的默认大小。 
           类似地,如果图像也是平铺的,则按照默认大小给出图块的宽度和高度。 
            通常情况下,宽度和高度的选择应使得宽度与高度之比非常接近的图像的纵横比,如从返回ImageReader.getAspectRatio 。 
 如果此插件不允许设置渲染大小,则会抛出UnsupportedOperationException 。 
 要删除渲染大小设置,请传递null的size 。 
size -一个 
            Dimension指示期望的宽度和高度。 
           IllegalArgumentException - 如果宽度或高度为负或为0。 
           UnsupportedOperationException - 如果此插件不支持图像调整大小。 
           getSourceRenderSize() , 
            ImageReader.getWidth(int) , 
            ImageReader.getHeight(int) , 
            ImageReader.getAspectRatio(int) 
           public Dimension getSourceRenderSize()
setSourceRenderSize方法设置,则返回源映像在解码过程中渲染的宽度和高度。 
           null值表示没有设置。 
          Dimension 。 
           setSourceRenderSize(java.awt.Dimension) 
           public void setSourceProgressivePasses(int minPass,
                                       int numPasses) 
          逐行通过是整个图像的重新编码,通常是逐渐更高的有效分辨率,但是需要更大的传输带宽。 逐行编码的最常用的用法是以JPEG格式发现,其中连续通过包括高频图像内容的更详细的表示。
 基于流中可用的实际通过次数,在解码期间确定要解码的实际传送次数。 因此,如果minPass + numPasses - 1大于最后可用路径的索引,解码将以该路径结束。 
 的值numPasses的Integer.MAX_VALUE表明,所有通行证minPass前应阅读。 否则,最后一次通过的指数( 即 minPass + numPasses - 1 )不能超过Integer.MAX_VALUE 。 
 没有unsetSourceProgressivePasses方法; 通过调用setSourceProgressivePasses(0, Integer.MAX_VALUE)可以获得相同的效果。 
minPass - 要解码的第一遍的索引。 
           numPasses - 要解码的最大通过次数。 
           IllegalArgumentException - 如果 
            minPass为负数,则 
            numPasses为负数或0,或 
            numPasses小于 
            Integer.MAX_VALUE但 
            minPass + numPasses - 1大于 
            INTEGER.MAX_VALUE 。 
           getSourceMinProgressivePass() , 
            getSourceMaxProgressivePass() 
           public int getSourceMinProgressivePass()
setSourceProgressivePasses(int, int) , 
            getSourceNumProgressivePasses() 
           public int getSourceMaxProgressivePass()
getSourceNumProgressivePasses等于Integer.MAX_VALUE ,则返回Integer.MAX_VALUE 。 
           否则返回getSourceMinProgressivePass() + getSourceNumProgressivePasses() - 1 。 
          Integer.MAX_VALUE 。 
           public int getSourceNumProgressivePasses()
Integer.MAX_VALUE (这是正确的值)。 
          setSourceProgressivePasses(int, int) , 
            getSourceMinProgressivePass() 
            Submit a bug or feature 
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
 Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.