public abstract class IIOParam extends Object
ImageReadParam和ImageWriteParam共享的所有变量和方法。 
       该类提供了指定源区域和目标区域的机制。 读取时,源是流,内存中的映像是目标。 写作时,这些都是相反的。 在写入的情况下,目的地区域可以仅与支持像素替换的写入器一起使用。
可以使用可移动的子采样网格为读者和作者指定抽取次采样。
可以选择源和目的地频带的子集。
| Modifier and Type | Field and Description | 
|---|---|
| protected IIOParamController | controller
              该 
              IIOParamController将用于提供此设置IIOParam对象时activateController方法被调用。 | 
| protected IIOParamController | defaultController
              当调用 
              activateController方法时,默认的IIOParamController将用于为此IIOParam对象提供设置。 | 
| protected Point | destinationOffset
              应放置左上角解码像素的目的地偏移量。 
             | 
| protected ImageTypeSpecifier | destinationType
              一个 
              ImageTypeSpecifier中使用读取操作时生成目标图像,或写入操作时设置输出颜色类型。 | 
| protected int[] | sourceBandsints的数组,int将使用哪些源频段,或null。 | 
| protected Rectangle | sourceRegion
              源区域, 
              null如果没有设置。 | 
| protected int | sourceXSubsampling
              在水平方向应用抽取次采样。 
             | 
| protected int | sourceYSubsampling
              在垂直方向应用抽取次采样。 
             | 
| protected int | subsamplingXOffset
              在采样之前应用于子采样网格的水平偏移。 
             | 
| protected int | subsamplingYOffset
              在二次采样之前应用于子采样网格的垂直偏移。 
             | 
| Modifier | Constructor and Description | 
|---|---|
| protected  | IIOParam()
              受保护的构造函数只能由子类调用。 
             | 
| Modifier and Type | Method and Description | 
|---|---|
| boolean | activateController()
              激活此 
              IIOParam对象的已IIOParamControllerIIOParam并返回结果值。 | 
| IIOParamController | getController()
              返回 
              IIOParamController安装的IIOParamController。 | 
| IIOParamController | getDefaultController()
              返回默认的 
              IIOParamController,如果有一个,不管当前安装的控制器。 | 
| Point | getDestinationOffset()
              返回目标图像中要放置像素的偏移量。 
             | 
| ImageTypeSpecifier | getDestinationType()
              返回由读返回图像的类型,如果是通过调用设置为 
              setDestination(ImageTypeSpecifier),为ImageTypeSpecifier。 | 
| int[] | getSourceBands()
              返回要使用的一组源频带。 
             | 
| Rectangle | getSourceRegion()
              返回要使用的源区域。 
             | 
| int | getSourceXSubsampling()
              返回每个像素前进的源列数。 
             | 
| int | getSourceYSubsampling()
              返回每个像素的行数。 
             | 
| int | getSubsamplingXOffset()
              返回子采样网格的水平偏移。 
             | 
| int | getSubsamplingYOffset()
              返回子采样网格的垂直偏移。 
             | 
| boolean | hasController()
              如果为此 
              IIOParam对象安装了控制器,则返回true。 | 
| void | setController(IIOParamController controller)
              设置 
              IIOParamController被用来提供用于此设置IIOParam对象时activateController方法被调用时,重写所有默认控制器。 | 
| void | setDestinationOffset(Point destinationOffset)
              指定目标图像中的未来解码像素的偏移量,读取时或写入区域的位置。 
             | 
| void | setDestinationType(ImageTypeSpecifier destinationType)
              使用 
              ImageTypeSpecifier设置目标图像所需的图像类型。 | 
| void | setSourceBands(int[] sourceBands)
              设置要使用的源频带的索引。 
             | 
| void | setSourceRegion(Rectangle sourceRegion)
              设置感兴趣的源区域。 
             | 
| void | setSourceSubsampling(int sourceXSubsampling, int sourceYSubsampling, int subsamplingXOffset, int subsamplingYOffset)
              指定抽取次采样以应用于I / O。 
             | 
protected Rectangle sourceRegion
null 。 
          protected int sourceXSubsampling
1 。 
           该值不能为负数或0。 
          protected int sourceYSubsampling
1 。 
           该值不能为负数或0。 
          protected int subsamplingXOffset
protected int subsamplingYOffset
protected int[] sourceBands
int的阵列int将使用哪些源频段,或null 。 
           如果null , null使用的源频带集合如在setSourceBands方法的注释中所述。 
           不应该允许任何价值为负数。 
          protected ImageTypeSpecifier destinationType
ImageTypeSpecifier中使用读取操作时生成目标图像,或写入操作时设置输出颜色类型。 
           如果未设置,则值为null 。 
           默认值为null 。 
          protected Point destinationOffset
protected IIOParamController defaultController
activateController方法时,默认的IIOParamController将用于为此IIOParam对象提供设置。 
           这个默认值应该由子类设置,选择提供自己的默认控制器(通常是GUI)来设置参数。 
          protected IIOParamController controller
IIOParamController将用于提供此设置IIOParam对象时activateController方法被调用。 
           此值覆盖任何默认控制器,即使为空。 
          public void setSourceRegion(Rectangle sourceRegion)
setSourceSubsampling采样因子。 
           如果子采样被设置为使得该数字为零,则将抛出IllegalStateException 。 
           由该方法指定的感兴趣的源区域将根据需要进行修剪以适应源边界以及实际I / O时的目标偏移量,宽度和高度。
 对于null , sourceRegion将删除任何区域规范,导致使用整个图像。 
sourceRegion - a 
            Rectangle感兴趣的源区域,或 
            null 。 
           IllegalArgumentException - 如果 
            sourceRegion是非 
            null和 
            sourceRegion.x或 
            sourceRegion.y是否定的。 
           IllegalArgumentException - 如果 
            sourceRegion是非 
            null和 
            sourceRegion.width或 
            sourceRegion.height是负数或0。 
           IllegalStateException - 如果子采样使得该区域将具有二次采样宽度或零度的高度。 
           getSourceRegion() , 
            setSourceSubsampling(int, int, int, int) , 
            setDestinationOffset(java.awt.Point) , 
            getDestinationOffset() 
           public Rectangle getSourceRegion()
setSourceRegion ,如果没有区域设置, null 。 
          Rectangle ,或 
            null 。 
           setSourceRegion(java.awt.Rectangle) 
           public void setSourceSubsampling(int sourceXSubsampling,
                                 int sourceYSubsampling,
                                 int subsamplingXOffset,
                                 int subsamplingYOffset) 
          sourceXSubsampling和sourceYSubsampling参数指定子采样周期( 即 ,每个源像素之后要提前的行数和列数)。 
           具体来说,1的周期将使用每行或列; 
           一个2的周期将使用每隔一行或一列。 
           subsamplingXOffset和subsamplingYOffset参数指定了第一个子采样像素的区域(或图像)原点的偏移。 
           调整子样本网格的原点对于在将非常大的源图像进行子采样到将被组装成完整的子采样图像的目的地区域时避免接缝是有用的。 
           大多数用户都希望将这些参数保留在0。 
           要使用的像素数和扫描线的数量如下计算。
扫描线中子采样像素的数量由下式给出
 truncate[(width - subsamplingXOffset + sourceXSubsampling - 1) / sourceXSubsampling] 。 
 如果该区域的宽度为零,则抛出IllegalStateException 。 
可以类似地计算要使用的扫描线的数量。
 如果该区域用于创建大图像的子采样图块,其中图块宽度和高度不是子采样周期的倍数,则将二次采样网格设置为开始于源区域原点以外的位置的功能非常有用。 如果子采样网格从块到块不保持一致,则在块边界处将存在伪像。 通过调整每个瓦片的子采样网格偏移量进行补偿,可以避免这些伪像。 折衷的是,为了避免这些工件,瓷砖的尺寸不一样。 在这种情况下使用的网格偏移量由下式给出: 
 网格偏移= [周期 - (区域偏移模周期)]模周期) 
 如果sourceXSubsampling或sourceYSubsampling为0或否,将抛出IllegalArgumentException 。 
 如果subsamplingXOffset或subsamplingYOffset为负数或大于或等于相应期间,则将抛出IllegalArgumentException 。 
 没有unsetSourceSubsampling方法; 只需调用setSourceSubsampling(1, 1, 0, 0)即可恢复默认值。 
sourceXSubsampling - 要在像素之间前进的列数。 
           sourceYSubsampling - 要在像素之间前进的行数。 
           subsamplingXOffset - 第一个子样本在该区域内的水平偏移,或者如果没有设置区域,则在图像内。 
           subsamplingYOffset - 区域内的第一个子样本的水平偏移量,如果没有设置区域,则在图像内。 
           IllegalArgumentException - 如果任一周期为负或为0,或者任一电网偏移为负或大于相应周期。 
           IllegalStateException - 如果源区域使得子采样输出将不包含像素。 
           public int getSourceXSubsampling()
 如果未调用setSourceSubsampling ,则返回1(正确的值)。 
setSourceSubsampling(int, int, int, int) , 
            getSourceYSubsampling() 
           public int getSourceYSubsampling()
 如果未调用setSourceSubsampling ,则返回1(正确的值)。 
setSourceSubsampling(int, int, int, int) , 
            getSourceXSubsampling() 
           public int getSubsamplingXOffset()
 如果未调用setSourceSubsampling ,则返回0(这是正确的值)。 
setSourceSubsampling(int, int, int, int) , 
            getSubsamplingYOffset() 
           public int getSubsamplingYOffset()
 如果未调用setSourceSubsampling ,则返回0(这是正确的值)。 
setSourceSubsampling(int, int, int, int) , 
            getSubsamplingXOffset() 
           public void setSourceBands(int[] sourceBands)
 null值表示将使用所有源频段。 
 在读出时,一个IllegalArgumentException将由读取器或写入如果已指定比最大可用源频带索引大的值抛出,或者如果要使用的源频带和目的地频带的数目是不同的。 ImageReader.checkReadParamBandSettings方法可用于自动化此测试。 
 语义上,一个副本是由阵列组成的; 对此调用后的数组内容的更改对此IIOParam没有任何影响。 
sourceBands - 要使用的整数带索引数组。 
           IllegalArgumentException - 如果 
            sourceBands包含负值或重复值。 
           getSourceBands() , 
            ImageReadParam.setDestinationBands(int[]) , 
            ImageReader.checkReadParamBandSettings(javax.imageio.ImageReadParam, int, int) 
           public int[] getSourceBands()
setSourceBands ,或null如果没有调用setSourceBands 。 
            语义上,返回的数组是一个副本; 对此调用后的数组内容的更改对此IIOParam没有任何影响。 
null 。 
           setSourceBands(int[]) 
           public void setDestinationType(ImageTypeSpecifier destinationType)
ImageTypeSpecifier设置目标图像的所需图像类型。 
            读取时,如果目标的布局已经使用这种方法设置,每次调用一个ImageReader read方法将返回一个新BufferedImage使用由所提供的类型说明符所指定的格式。 作为副作用,任何目的地BufferedImage通过设置ImageReadParam.setDestination(BufferedImage)将不再被设定为目的地。 换句话说,这种方法可以被认为是调用setDestination((BufferedImage)null) 。 
 当写入时,目的地类型可能用于确定图像的颜色类型。 SampleModel信息将被忽略,可能是null 。 例如,4带图像可以表示CMYK或RGBA数据。 如果设置了目的地类型,其ColorModel将覆盖图像本身上的任何ColorModel 。 当使用setSourceBands时,这是至关重要的,因为图像的ColorModel将引用整个图像,而不是被写入的带子集。 
destinationType -的 
            ImageTypeSpecifier被用来确定目标布局和颜色类型。 
           getDestinationType() 
           public ImageTypeSpecifier getDestinationType()
setDestination(ImageTypeSpecifier) ,为ImageTypeSpecifier 。 
           如果没有设置,返回null 。 
          ImageTypeSpecifier类型的ImageTypeSpecifier,或 
            null 。 
           setDestinationType(javax.imageio.ImageTypeSpecifier) 
           public void setDestinationOffset(Point destinationOffset)
 当读取时,要在目的地BufferedImage写入的区域将从该偏移开始,并且具有由感兴趣的源区域,子采样参数和目的地边界确定的宽度和高度。 
 正常写入不受此方法的影响,只能使用ImageWriter.replacePixels执行写操作。 对于这样的写入,指定的偏移量在其像素被修改的输出流图像内。 
 没有unsetDestinationOffset方法; 只需调用setDestinationOffset(new Point(0, 0))即可恢复默认值。 
destinationOffset - 
            destinationOffset的偏移量,如 
            Point 。 
           IllegalArgumentException - 如果 
            destinationOffset是 
            null 。 
           getDestinationOffset() , 
            ImageWriter.replacePixels(java.awt.image.RenderedImage, javax.imageio.ImageWriteParam) 
           public Point getDestinationOffset()
 如果setDestinationOffsets没有被调用,一个Point零X和Y值返回(这是正确的值)。 
Point 。 
           setDestinationOffset(java.awt.Point) 
           public void setController(IIOParamController controller)
IIOParamController被用来提供用于此设置IIOParam对象时activateController方法被调用时,重写所有默认控制器。 
           如果参数为null ,则不会使用任何控制器,包括任何默认值。 
           要恢复默认值,请使用setController(getDefaultController()) 。 
          controller - 适当的 
            IIOParamController或 
            null 。 
           IIOParamController , getController() , getDefaultController() , hasController() , activateController() 
           public IIOParamController getController()
IIOParamController安装的IIOParamController。 
           如果有一个null或最近调用setController的参数,这可能是默认值。 
          IIOParamController或 
            null 。 
           IIOParamController , setController(javax.imageio.IIOParamController) , getDefaultController() , hasController() , activateController() 
           public IIOParamController getDefaultController()
IIOParamController ,如果有一个,不管当前安装的控制器。 
           如果没有默认控制器,则返回null 。 
          IIOParamController ,或 
            null 。 
           IIOParamController , setController(IIOParamController) , getController() , hasController() , activateController() 
           public boolean hasController()
IIOParam对象安装了控制器,则返回true 。 
           这将返回true如果getController不会返回null 。 
          true如果安装了控制器。 
           IIOParamController , setController(IIOParamController) , getController() , getDefaultController() , activateController() 
           public boolean activateController()
IIOParam对象的安装IIOParamController ,并返回结果值。 
           当此方法返回true时,此IIOParam对象的所有值将准备好进行下一次读或写操作。 
           如果返回false ,则此对象中的设置不会受到干扰( 即用户取消了该操作)。 
            通常,控制器将提供的一个子类的用户界面的GUI IIOParam用于特定插件。 控制器不需要GUI。 
true如果控制器正常完成。 
           IllegalStateException - 如果当前没有安装控制器。 
           IIOParamController , setController(IIOParamController) , getController() , getDefaultController() , hasController() 
            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.