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
目的条带要使用的设置,作为
int s数组。
|
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, setSourceSubsampling
protected 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
s数组。默认情况下,该值是
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
对应的一个ImageTypeSpecifier
s从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
方法。一个
null
value表示没有设置了。
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.