public class ImageReadParam extends IIOParam
ImageReader供应规定“如何做”的信息。
作为一个文件或流的一部分编码的图像可能被认为在多个维度扩展:宽度和高度的空间尺寸,一些频带,和一个渐进的解码通过。这个类允许一个连续的(超)在所有这些尺寸图像的矩形分区被选定为解码。此外,空间尺寸可间断采样。最后,颜色和格式的转换可以通过控制目标图像的ColorModel和SampleModel指定,或者通过提供BufferedImage或通过使用ImageTypeSpecifier。
一个ImageReadParam对象用于指定一个图像,或一组图像,将图像中的java I/O框架下的流输入转换。一个插件为特定的图像格式将从其ImageReader实施getDefaultReadParam ImageReadParam实例方法。
国家通过ImageReadParam实例保持独立于任何特定的图像解码。当实际的解码需要的地方,设置的值在读取参数结合图像从流和目的BufferedImage将接收解码的像素数据解码的实际性能。例如,使用setSourceRegion设置源区首先将相交的实际有效的源区。结果将返回的值转换getDestinationOffset,以及由此产生的矩形相交的实际有效的目标区域产量目标区域,将写。
通过ImageReadParam指定的参数应用于图像如下。首先,如果一个渲染尺寸已定的setSourceRenderSize,整个解码图像是由getSourceRenderSize大小呈现。否则,形象有其天然的大小和ImageReader.getHeight给予ImageReader.getWidth。
其次,图像卡对getSourceXOffset,getSourceYOffset,getSourceWidth指定的源区,和getSourceHeight。
由此产生的区域,然后根据给定的采样IIOParam.setSourceSubsampling因素。第一像素,每行的像素点的数量,与行数都取决于采样设置。电话最小的x和y坐标的矩形(minX,minY),其宽度和高度h w。
这个矩形偏移(getDestinationOffset().x,getDestinationOffset().y)和剪切对目的地的界限。如果没有目的地形象已定,目的地是指有宽getDestinationOffset().x + w,和高度getDestinationOffset().y + h使所有像素的源区可能写入目标。
像素的土地,经过抽样、目标图像中,这是写在一个进步的经过getSourceMinProgressivePass和getSourceNumProgressivePasses指定传递到下一步。
最后,每个像素被映射到源样品的目的条带根据算法在评论中描述的setDestinationBands。
塞在作家可能通过提供一个类实现额外的扩展功能插件ImageReadParam,特定的接口。它是由插件来记录什么接口是可用的,以及它们是如何被使用的。读者会默默地忽略任何扩展功能的其中一个ImageReadParam类的他们不知道。同时,他们可能忽略任何可选的功能,他们通常禁用在创建自己的ImageReadParam实例通过getDefaultReadParam。
注意,除非有能力查询的方法是存在的,它必须由所有ImageReader实现支持(例如源渲染尺寸是可选的,但抽样必须支持)。
ImageReader,
ImageWriter,
ImageWriteParam
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
canSetSourceRenderSize
如果这
true
ImageReadParam允许源渲染尺寸设置。
|
protected BufferedImage |
destination
当前的目标
BufferedImage,或
null如果没有设置。
|
protected int[] |
destinationBands
目的条带要使用的设置,作为
ints数组。
|
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()
返回由
setDestination方法目前设置
BufferedImage,或
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。子类必须手动设置此值。
ImageReaders不支持设置源渲染尺寸应将此值设置为false。
protected Dimension sourceRenderSize
canSetSourceRenderSize是
true,或
null。
ImageReaders不支持设置源渲染尺寸可以忽略这个值。
protected BufferedImage destination
BufferedImage,或
null如果没有设置。默认情况下,该值是
null。
protected int[] destinationBands
ints数组。默认情况下,该值是
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-banded图像表现为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对应的一个ImageTypeSpecifiers从ImageReader的getImageTypes方法返回。如果不是这样,读者将抛出一个IIOException。
destination的BufferedImage被写入,或
null。
getDestination()
public BufferedImage getDestination()
setDestination方法目前设置
BufferedImage,或
null如果没有设置。
setDestination(java.awt.image.BufferedImage)
public void setDestinationBands(int[] destinationBands)
一个null值表示所有的目的条带将使用。
选择一个目标带子集将不会影响在一个读取的输出图像的频带的数量,如果没有目标图像被指定;所创建的目的Map像将仍然有相同数量的频带,如果这种方法从来没有被调用。如果在目的地形象的不同波段图像所需的,必须提供使用ImageReadParam.setDestination方法。
在阅读或写作的时候,一个IllegalArgumentException将被读者或作家,如果一个值大于最大目标波段指数已指定,或者是用不同的源和目的条带数条。的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和
ImageReader
getHeight方法此方法不受影响;他们将继续返回图像的默认大小。同样,如果图像也瓷砖的瓷砖宽度和高度,给出了默认大小。
通常,宽度和高度应选择这样的宽度和高度的比率接近图像的纵横比,作为ImageReader.getAspectRatio归来。
如果这个插件不允许渲染的大小进行设置,将抛出一UnsupportedOperationException。
除去渲染尺寸设置,为size传递一个值null。
size -
Dimension指示所需的宽度和高度。
IllegalArgumentException如果的宽度或高度为负或0。
UnsupportedOperationException如果图像大小不受该插件的支持。
getSourceRenderSize(),
ImageReader.getWidth(int),
ImageReader.getHeight(int),
ImageReader.getAspectRatio(int)
public Dimension getSourceRenderSize()
setSourceRenderSize方法。一个
nullvalue表示没有设置了。
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.