public class ComponentSampleModel extends SampleModel
DataBuffer.TYPE_BYTE , DataBuffer.TYPE_USHORT ,或DataBuffer.TYPE_INT ,分别地),数据为每个样本是一个带符号的整数,其可以被存储在16位(使用DataBuffer.TYPE_SHORT ),或数据,其中每个样本是一个带符号的浮点或双精度的数量(使用DataBuffer.TYPE_FLOAT或DataBuffer.TYPE_DOUBLE分别)。
给定ComponentSampleModel的所有样本以相同的精度存储。
所有步幅和偏移量必须为非负值。
该类支持TYPE_BYTE , TYPE_USHORT , TYPE_SHORT , TYPE_INT , TYPE_FLOAT , TYPE_DOUBLE ,
| Modifier and Type | Field and Description |
|---|---|
protected int[] |
bandOffsets
数据数组元素中所有频带的偏移量。
|
protected int[] |
bankIndices
每个存储一组图像数据的存储体的索引。
|
protected int |
numBands
这个频数在
ComponentSampleModel 。
|
protected int |
numBanks
这笔
ComponentSampleModel的银行数量。
|
protected int |
pixelStride
由该ComponentSampleModel描述的图像数据区域的像素(在数据数组元素中)。
|
protected int |
scanlineStride
由该ComponentSampleModel描述的图像数据区域的线条(在数据数组元素中)。
|
dataType, height, width| Constructor and Description |
|---|
ComponentSampleModel(int dataType, int w, int h, int pixelStride, int scanlineStride, int[] bandOffsets)
使用指定的参数构造一个ComponentSampleModel。
|
ComponentSampleModel(int dataType, int w, int h, int pixelStride, int scanlineStride, int[] bankIndices, int[] bandOffsets)
使用指定的参数构造一个ComponentSampleModel。
|
| Modifier and Type | Method and Description |
|---|---|
SampleModel |
createCompatibleSampleModel(int w, int h)
创建一个新的
ComponentSampleModel具有指定的宽度和高度。
|
DataBuffer |
createDataBuffer()
创建一个
DataBuffer对应于这个
ComponentSampleModel 。
|
SampleModel |
createSubsetSampleModel(int[] bands)
使用此ComponentSampleModel的带子集创建新的ComponentSampleModel。
|
boolean |
equals(Object o)
指示一些其他对象是否等于此。
|
int[] |
getBandOffsets()
返回所有频段的频偏。
|
int[] |
getBankIndices()
返回所有频段的银行指数。
|
Object |
getDataElements(int x, int y, Object obj, DataBuffer data)
在类型的原始阵列中的单个像素返回数据
TransferType 。
|
int |
getNumDataElements()
|
int |
getOffset(int x, int y)
获取像素(x,y)的第一个带的偏移量。
|
int |
getOffset(int x, int y, int b)
获取像素(x,y)的带b的偏移。
|
int[] |
getPixel(int x, int y, int[] iArray, DataBuffer data)
返回int数组中指定像素的所有样本,每个数组元素一个样本。
|
int[] |
getPixels(int x, int y, int w, int h, int[] iArray, DataBuffer data)
返回int数组中指定的像素矩形的所有样本,每个数组元素一个样本。
|
int |
getPixelStride()
返回此ComponentSampleModel的像素步幅。
|
int |
getSample(int x, int y, int b, DataBuffer data)
返回为位于(x,y)处的像素的指定带中的样本int。
|
double |
getSampleDouble(int x, int y, int b, DataBuffer data)
将位于(x,y)的像素的指定带中的样本返回为双倍。
|
float |
getSampleFloat(int x, int y, int b, DataBuffer data)
将位于(x,y)处的像素的指定带中的样本作为浮点返回。
|
int[] |
getSamples(int x, int y, int w, int h, int b, int[] iArray, DataBuffer data)
返回int数组中指定的像素矩形的指定带中的样本,每个数据数组元素一个样本。
|
int[] |
getSampleSize()
返回所有频带的每个样本的位数。
|
int |
getSampleSize(int band)
返回指定频带的每个样本的位数。
|
int |
getScanlineStride()
返回此ComponentSampleModel的扫描线步幅。
|
int |
hashCode()
返回对象的哈希码值。
|
void |
setDataElements(int x, int y, Object obj, DataBuffer data)
设置在指定的一个单个像素的数据
DataBuffer从类型的基本数组
TransferType 。
|
void |
setPixel(int x, int y, int[] iArray, DataBuffer data)
在
DataBuffer中设置一个像素,使用int数组的样本进行输入。
|
void |
setPixels(int x, int y, int w, int h, int[] iArray, DataBuffer data)
从包含每个数组元素一个样本的int数组中设置一个像素矩形的所有样本。
|
void |
setSample(int x, int y, int b, double s, DataBuffer data)
设置在在位于(x,y)的像素的指定频带中的样品
DataBuffer使用双输入。
|
void |
setSample(int x, int y, int b, float s, DataBuffer data)
在
DataBuffer使用浮点数为输入设置位于(x,y)处的像素的指定波段的样本。
|
void |
setSample(int x, int y, int b, int s, DataBuffer data)
在
DataBuffer使用int作为输入,为位于(x,y)的像素的指定频带设置一个样本。
|
void |
setSamples(int x, int y, int w, int h, int b, int[] iArray, DataBuffer data)
从包含每个数据数组元素一个样本的int数组中为指定的像素矩形设置样本。
|
getDataElements, getDataType, getHeight, getNumBands, getPixel, getPixel, getPixels, getPixels, getSamples, getSamples, getTransferType, getWidth, setDataElements, setPixel, setPixel, setPixels, setPixels, setSamples, setSamplesprotected int[] bandOffsets
protected int[] bankIndices
protected int numBands
ComponentSampleModel的乐队数量。
protected int numBanks
ComponentSampleModel 。
protected int scanlineStride
protected int pixelStride
public ComponentSampleModel(int dataType,
int w,
int h,
int pixelStride,
int scanlineStride,
int[] bandOffsets)
dataType - 存储样本的数据类型
w - 描述的图像数据区域的宽度(以像素为单位)
h - 描述的图像数据区域的高度(以像素为单位)
pixelStride - 描述图像数据区域的像素步幅
scanlineStride - 所描述的图像数据区域的行走
bandOffsets - 所有频段的偏移量
IllegalArgumentException - 如果
w或
h不大于0
IllegalArgumentException - 如果
pixelStride小于0
IllegalArgumentException - 如果
scanlineStride小于0
IllegalArgumentException - 如果
numBands小于1
IllegalArgumentException - 如果
w和
h的产品大于
Integer.MAX_VALUE
IllegalArgumentException - 如果
dataType不是支持的数据类型之一
public ComponentSampleModel(int dataType,
int w,
int h,
int pixelStride,
int scanlineStride,
int[] bankIndices,
int[] bandOffsets)
dataType - 存储样本的数据类型
w - 描述的图像数据区域的宽度(以像素为单位)
h - 描述的图像数据区域的高度(以像素为单位)
pixelStride - 描述图像数据区域的像素步幅
scanlineStride - 描述图像数据区域的行走
bankIndices - 所有乐队的银行指数
bandOffsets - 所有频带的频带偏移量
IllegalArgumentException - 如果
w或
h不大于0
IllegalArgumentException - 如果
pixelStride小于0
IllegalArgumentException - 如果
scanlineStride小于0
IllegalArgumentException -如果长度
bankIndices不等于的长度
bankOffsets
IllegalArgumentException -如有的银行指数
bandIndices小于0
IllegalArgumentException - 如果
dataType不是支持的数据类型之一
public SampleModel createCompatibleSampleModel(int w, int h)
ComponentSampleModel 。
新SampleModel将具有相同数目的频带,存储数据类型的交织方案,以及像素跨度,因为这SampleModel 。
createCompatibleSampleModel在
SampleModel
w - 所得的宽度
SampleModel
h - 所得的高度
SampleModel
ComponentSampleModel与指定的大小
IllegalArgumentException - 如果
w或
h不大于0
public SampleModel createSubsetSampleModel(int[] bands)
createSubsetSampleModel在
SampleModel
bands - 这个
ComponentSampleModel的频带子集
ComponentSampleModel创建与这个
ComponentSampleModel集。
public DataBuffer createDataBuffer()
DataBuffer对应于这个ComponentSampleModel 。
DataBuffer对象的数据类型,银行数量和大小与此ComponentSampleModel 。
createDataBuffer在
SampleModel
DataBuffer ,其数据类型,数量和大小与此
ComponentSampleModel 。
public int getOffset(int x,
int y)
DataBuffer data ,其中ComponentSampleModel csm为
data.getElem(csm.getOffset(x, y));
x - 像素的X位置
y - 像素的Y位置
public int getOffset(int x,
int y,
int b)
b可以从被检索DataBuffer data与ComponentSampleModel csm作为
data.getElem(csm.getOffset(x, y, b));
x - 指定像素的X位置
y - 指定像素的Y位置
b - 指定的乐队
public final int[] getSampleSize()
getSampleSize在
SampleModel
public final int getSampleSize(int band)
getSampleSize在
SampleModel
band - 指定乐队
public final int[] getBankIndices()
public final int[] getBandOffsets()
public final int getScanlineStride()
ComponentSampleModel 。
public final int getPixelStride()
ComponentSampleModel的像素步幅。
public final int getNumDataElements()
getDataElements(int, int, Object, DataBuffer)和setDataElements(int, int, Object, DataBuffer)方法传输像素所需的数据元素数。
对于ComponentSampleModel ,这与频带数相同。
getNumDataElements在
SampleModel
getDataElements和
setDataElements方法传输像素所需的数据元素数量。
SampleModel.getNumDataElements() ,
SampleModel.getNumBands()
public Object getDataElements(int x, int y, Object obj, DataBuffer data)
TransferType 。
对于ComponentSampleModel ,这与数据类型相同,并且每个数组元素返回一个样本。
通常, obj应传递在如null ,使得Object被自动创建,并且是右原始数据类型。
以下代码说明了从DataBuffer db1一个像素的数据,其存储布局由ComponentSampleModel csm1为DataBuffer db2 ,其存储布局由ComponentSampleModel csm2 。 转移通常比使用getPixel和setPixel更setPixel 。
ComponentSampleModel csm1, csm2;
DataBufferInt db1, db2;
csm2.setDataElements(x, y,
csm1.getDataElements(x, y, null, db1), db2);
使用getDataElements和setDataElements在两个DataBuffer/SampleModel对之间传输是合法的,如果SampleModel对象具有相同数量的频带,则相应频带具有与每个样本相同的位数,并且TransferType是相同的。
如果obj不是null ,它应该是类型的基本数组TransferType 。 否则,抛出一个ClassCastException 。 一个ArrayIndexOutOfBoundsException如果坐标不在边界可能被抛出,或者如果obj不null并没有大到足以容纳像素数据。
getDataElements在
SampleModel
x - 像素位置的X坐标
y - 像素位置的Y坐标
obj - 如果非
null是要返回像素数据的原始数组
data - 包含图像数据的
DataBuffer
NullPointerException - 如果数据为空。
ArrayIndexOutOfBoundsException - 如果坐标不在边界内,或者obj太小,不能容纳输出。
setDataElements(int, int, Object, DataBuffer)
public int[] getPixel(int x,
int y,
int[] iArray,
DataBuffer data)
ArrayIndexOutOfBoundsException如果坐标不在边界可能被抛出。
getPixel在
SampleModel
x - 像素位置的X坐标
y - 像素位置的Y坐标
iArray - 如果非空,则返回此数组中的样本
data - 包含图像数据的DataBuffer
NullPointerException - 如果数据为空。
ArrayIndexOutOfBoundsException - 如果坐标不在边界,或者如果iArray太小,不能容纳输出。
setPixel(int, int, int[], DataBuffer)
public int[] getPixels(int x,
int y,
int w,
int h,
int[] iArray,
DataBuffer data)
ArrayIndexOutOfBoundsException如果坐标不在边界可能被抛出。
getPixels在
SampleModel
x - 左上角像素位置的X坐标
y - 左上角像素位置的Y坐标
w - 像素矩形的宽度
h - 像素矩形的高度
iArray - 如果非空,则返回此数组中的样本
data - 包含图像数据的DataBuffer
setPixels(int, int, int, int, int[], DataBuffer)
public int getSample(int x,
int y,
int b,
DataBuffer data)
ArrayIndexOutOfBoundsException如果坐标不在边界可能被抛出。
getSample在
SampleModel
x - 像素位置的X坐标
y - 像素位置的Y坐标
b - 乐队返回
data - 包含图像数据的
DataBuffer
setSample(int, int, int, int, DataBuffer)
public float getSampleFloat(int x,
int y,
int b,
DataBuffer data)
ArrayIndexOutOfBoundsException如果坐标不在边界可能被抛出。
getSampleFloat在
SampleModel
x - 像素位置的X坐标
y - 像素位置的Y坐标
b - 乐队返回
data - 包含图像数据的DataBuffer
public double getSampleDouble(int x,
int y,
int b,
DataBuffer data)
ArrayIndexOutOfBoundsException如果坐标不在边界可能被抛出。
getSampleDouble在
SampleModel
x - 像素位置的X坐标
y - 像素位置的Y坐标
b - 乐队返回
data - 包含图像数据的DataBuffer
public int[] getSamples(int x,
int y,
int w,
int h,
int b,
int[] iArray,
DataBuffer data)
ArrayIndexOutOfBoundsException如果坐标不在边界可能被抛出。
getSamples在
SampleModel类
x - 左上角像素位置的X坐标
y - 左上角像素位置的Y坐标
w - 像素矩形的宽度
h - 像素矩形的高度
b - 乐队返回
iArray - 如果非
null返回此数组中的样本
data - 包含图像数据的
DataBuffer
setSamples(int, int, int, int, int, int[], DataBuffer)
public void setDataElements(int x,
int y,
Object obj,
DataBuffer data)
DataBuffer从类型的基本数组TransferType 。
对于ComponentSampleModel ,这与数据类型相同,并且样本每个数组元素传输一个。
以下代码说明了从DataBuffer db1一个像素的数据,其存储布局由ComponentSampleModel csm1为DataBuffer db2 ,其存储布局由ComponentSampleModel csm2 。 转移通常比使用getPixel和setPixel更setPixel 。
ComponentSampleModel csm1, csm2;
DataBufferInt db1, db2;
csm2.setDataElements(x, y, csm1.getDataElements(x, y, null, db1),
db2);
如果SampleModel对象具有相同数量的频带,则使用getDataElements和setDataElements在两个DataBuffer/SampleModel对之间传输是合法的,对应的频带具有与每个样本相同的位数,并且TransferType是相同的。
甲ClassCastException如果被抛出obj不是类型的基本数组TransferType 。 一个ArrayIndexOutOfBoundsException如果坐标不在边界可能被抛出,或者如果obj不够大,无法容纳像素数据。
setDataElements在
SampleModel类
x - 像素位置的X坐标
y - 像素位置的Y坐标
obj - 包含像素数据的原始数组
data - 包含图像数据的DataBuffer
getDataElements(int, int, Object, DataBuffer)
public void setPixel(int x,
int y,
int[] iArray,
DataBuffer data)
DataBuffer使用int数组的样本设置一个像素进行输入。
一个ArrayIndexOutOfBoundsException如果坐标不在边界可能被抛出。
setPixel在
SampleModel
x - 像素位置的X坐标
y - 像素位置的Y坐标
iArray - int数组中的输入样本
data - 包含图像数据的DataBuffer
getPixel(int, int, int[], DataBuffer)
public void setPixels(int x,
int y,
int w,
int h,
int[] iArray,
DataBuffer data)
ArrayIndexOutOfBoundsException如果坐标不在边界可能被抛出。
setPixels在
SampleModel类
x - 左上角像素位置的X坐标
y - 左上角像素位置的Y坐标
w - 像素矩形的宽度
h - 像素矩形的高度
iArray - int数组中的输入样本
data - 包含图像数据的DataBuffer
getPixels(int, int, int, int, int[], DataBuffer)
public void setSample(int x,
int y,
int b,
int s,
DataBuffer data)
DataBuffer使用int作为输入,为位于(x,y)处的像素的指定频带设置一个样本。
一个ArrayIndexOutOfBoundsException如果坐标不在边界可能被抛出。
setSample在
SampleModel
x - 像素位置的X坐标
y - 像素位置的Y坐标
b - 乐队设置
s - 输入样本为int
data - 包含图像数据的DataBuffer
getSample(int, int, int, DataBuffer)
public void setSample(int x,
int y,
int b,
float s,
DataBuffer data)
DataBuffer使用浮点数为输入设置位于(x,y)处的像素的指定波段的样本。
一个ArrayIndexOutOfBoundsException如果坐标不在边界可能被抛出。
setSample在
SampleModel类
x - 像素位置的X坐标
y - 像素位置的Y坐标
b - 乐队设置
s - 输入样本为浮点数
data - 包含图像数据的DataBuffer
getSample(int, int, int, DataBuffer)
public void setSample(int x,
int y,
int b,
double s,
DataBuffer data)
DataBuffer使用双倍的输入设置位于(x,y)处的像素的指定频带中的样本。
一个ArrayIndexOutOfBoundsException如果坐标不在边界可能被抛出。
setSample在
SampleModel
x - 像素位置的X坐标
y - 像素位置的Y坐标
b - 乐队设置
s - 输入样本为双倍
data - 包含图像数据的DataBuffer
getSample(int, int, int, DataBuffer)
public void setSamples(int x,
int y,
int w,
int h,
int b,
int[] iArray,
DataBuffer data)
ArrayIndexOutOfBoundsException如果坐标不在边界可能被抛出。
setSamples在
SampleModel类
x - 左上角像素位置的X坐标
y - 左上角像素位置的Y坐标
w - 像素矩形的宽度
h - 像素矩形的高度
b - 乐队设定
iArray - int数组中的输入样本
data - 包含图像数据的DataBuffer
getSamples(int, int, int, int, int, int[], DataBuffer)
public boolean equals(Object o)
Object
equals方法在非空对象引用上实现等价关系:
x , x.equals(x)应该返回true 。 x和y , x.equals(y)应该返回true当且仅当y.equals(x)回报true 。 x , y和z ,如果x.equals(y)回报true个y.equals(z)回报true ,然后x.equals(z)应该返回true 。 x和y ,多次调用x.equals(y)始终返回true或一致返回false ,前提是没有使用equals对象进行比较的信息被修改。 x , x.equals(null)应该返回false 。 该equals类方法Object实现对象上差别可能性最大的相等关系; 也就是说,对于任何非空引用值x和y ,当且仅当x和y引用相同的对象( x == y具有值true )时,此方法返回true 。
请注意,当覆盖此方法时,通常需要覆盖hashCode方法,以便维护hashCode方法的通用合同,该方法规定相等的对象必须具有相等的哈希码。
equals在
Object
o - 与之比较的参考对象。
true如果此对象与obj参数相同;
false否则。
Object.hashCode() , HashMap
public int hashCode()
Object
HashMap提供的哈希表的优点 。
hashCode的总合同是:
hashCode方法必须始终返回相同的整数,前提是修改了对象中equals比较中的信息。 该整数不需要从一个应用程序的执行到相同应用程序的另一个执行保持一致。 equals(Object)方法两个对象相等,则在两个对象中的每个对象上调用hashCode方法必须产生相同的整数结果。 Object.equals(java.lang.Object)方法不相等,那么在两个对象中的每个对象上调用hashCode方法必须产生不同的整数结果。 但是,程序员应该意识到,为不等对象生成不同的整数结果可能会提高哈希表的性能。 尽可能合理实用,由类Object定义的hashCode方法确实为不同对象返回不同的整数。 (这通常通过将对象的内部地址转换为整数来实现,但Java的编程语言不需要此实现技术。)
hashCode在
Object
Object.equals(java.lang.Object) ,
System.identityHashCode(java.lang.Object)
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.