- java.lang.Object
-
- java.awt.image.Raster
-
- 已知直接子类:
-
WritableRaster
public class Raster extends Object
表示矩形像素数组的类。 Raster封装了一个存储样本值的DataBuffer和一个描述如何在DataBuffer中定位给定样本值的SampleModel。栅格定义占据平面的特定矩形区域的像素的值,不一定包括(0,0)。 矩形,称为Raster的边界矩形,可通过getBounds方法获得,由minX,minY,width和height值定义。 minX和minY值定义Raster左上角的坐标。 对边界矩形之外的像素的引用可能导致抛出异常,或者可能导致对Raster的关联DataBuffer的非预期元素的引用。 用户有责任避免访问此类像素。
SampleModel描述了Raster的样本如何存储在DataBuffer的原始数组元素中。 可以在每个数据元素中存储一个样本,如在PixelInterleavedSampleModel或BandedSampleModel中,或者将几个打包到元素,如在SinglePixelPackedSampleModel或MultiPixelPackedSampleModel中。 SampleModel还控制是否对样本进行符号扩展,允许将无符号数据存储在已签名的Java数据类型(如byte,short和int)中。
虽然Raster可以存在于平面中的任何位置,但SampleModel使用从(0,0)开始的简单坐标系。 因此,Raster包含一个转换因子,允许在Raster的坐标系和SampleModel的坐标系之间映射像素位置。 可以通过getSampleModelTranslateX和getSampleModelTranslateY方法获得从SampleModel坐标系到Raster的坐标系的转换。
Raster可以通过显式构造或使用createChild和createTranslatedChild方法与另一个Raster共享DataBuffer。 通过这些方法创建的栅格可以通过getParent方法返回对它们创建的栅格的引用。 对于未通过调用createTranslatedChild或createChild构造的Raster,getParent将返回null。
createTranslatedChild方法返回一个新的Raster,它共享当前Raster的所有数据,但占用一个宽度和高度相同但起点不同的边界矩形。 例如,如果父Raster占用了区域(10,10)到(100,100),并且翻译的Raster被定义为从(50,50)开始,那么父和像素的像素(20,20)( 60,60)的孩子占据了两个Rasters共享的DataBuffer中的相同位置。 在第一种情况下,应将(-10,-10)添加到像素坐标以获得相应的SampleModel坐标,并且在第二种情况下(-50,-50)应添加。
可以通过从父项的那些中减去子项的sampleModelTranslateX和sampleModelTranslateY值来确定父项和子项Raster之间的转换。
createChild方法可用于创建新Raster,仅占用其父级边界矩形的子集(具有相同或已转换的坐标系)或其父级的子带子集。
所有构造函数都受到保护。 创建Raster的正确方法是使用此类中定义的静态创建方法之一。 这些方法创建使用标准Interleaved,Banded和Packed SampleModel的Raster实例,并且可以比通过组合外部生成的SampleModel和DataBuffer创建的Raster更有效地处理。
-
-
字段汇总
字段 变量和类型 字段 描述 protected DataBufferdataBuffer存储图像数据的DataBuffer。protected intheight这个光栅的高度。protected intminX此Raster左上角像素的X坐标。protected intminY此Raster左上角像素的Y坐标。protected intnumBands栅格中的波段数。protected intnumDataElements每个像素的DataBuffer数据元素的数量。protected Rasterparent此Raster的父级,或null。protected SampleModelsampleModelSampleModel描述了此Raster中的像素如何存储在DataBuffer中。protected intsampleModelTranslateX从Raster的SampleModel的坐标空间到Raster的坐标空间的X平移。protected intsampleModelTranslateY从Raster的SampleModel的坐标空间到Raster的坐标空间的Y平移。protected intwidth此光栅的宽度。
-
构造方法摘要
构造方法 变量 构造器 描述 protectedRaster(SampleModel sampleModel, DataBuffer dataBuffer, Point origin)使用给定的SampleModel和DataBuffer构造一个Raster。protectedRaster(SampleModel sampleModel, DataBuffer dataBuffer, Rectangle aRegion, Point sampleModelTranslate, Raster parent)使用给定的SampleModel,DataBuffer和parent构造一个Raster。protectedRaster(SampleModel sampleModel, Point origin)使用给定的SampleModel构造一个Raster。
-
方法摘要
所有方法 静态方法 实例方法 具体的方法 变量和类型 方法 描述 static WritableRastercreateBandedRaster(int dataType, int w, int h, int scanlineStride, int[] bankIndices, int[] bandOffsets, Point location)基于BandedSampleModel创建一个Raster,其中包含指定的数据类型,宽度,高度,扫描行间距,行索引和波段偏移。static WritableRastercreateBandedRaster(int dataType, int w, int h, int bands, Point location)基于BandedSampleModel创建一个Raster,其中包含指定的数据类型,宽度,高度和band数。static WritableRastercreateBandedRaster(DataBuffer dataBuffer, int w, int h, int scanlineStride, int[] bankIndices, int[] bandOffsets, Point location)基于BandedSampleModel创建一个Raster,其中包含指定的DataBuffer,width,height,scanline stride,bank indices和band offset。RastercreateChild(int parentX, int parentY, int width, int height, int childMinX, int childMinY, int[] bandList)返回一个新的Raster,它共享此Raster的DataBuffer的全部或部分内容。WritableRastercreateCompatibleWritableRaster()使用相同的SampleModel和新的初始化DataBuffer创建与此Raster大小相同的兼容WritableRaster。WritableRastercreateCompatibleWritableRaster(int w, int h)创建具有指定大小的兼容WritableRaster,新的SampleModel和新初始化的DataBuffer。WritableRastercreateCompatibleWritableRaster(int x, int y, int w, int h)创建一个兼容的WritableRaster,它具有指定的位置(minX,minY)和大小(宽度,高度),一个新的SampleModel和一个新的初始化DataBuffer。WritableRastercreateCompatibleWritableRaster(Rectangle rect)创建兼容的WritableRaster,其中包含由rect指定的位置(minX,minY)和大小(宽度,高度),新的SampleModel和新的初始化DataBuffer。static WritableRastercreateInterleavedRaster(int dataType, int w, int h, int scanlineStride, int pixelStride, int[] bandOffsets, Point location)基于PixelInterleavedSampleModel创建一个Raster,其中包含指定的数据类型,宽度,高度,扫描行间距,像素跨度和波段偏移。static WritableRastercreateInterleavedRaster(int dataType, int w, int h, int bands, Point location)基于PixelInterleavedSampleModel创建一个Raster,其中包含指定的数据类型,宽度,高度和band数。static WritableRastercreateInterleavedRaster(DataBuffer dataBuffer, int w, int h, int scanlineStride, int pixelStride, int[] bandOffsets, Point location)基于PixelInterleavedSampleModel创建一个Raster,其中包含指定的DataBuffer,width,height,scanline stride,pixel stride和band offset。static WritableRastercreatePackedRaster(int dataType, int w, int h, int[] bandMasks, Point location)基于具有指定数据类型,宽度,高度和波段掩码的SinglePixelPackedSampleModel创建栅格。static WritableRastercreatePackedRaster(int dataType, int w, int h, int bands, int bitsPerBand, Point location)基于打包的SampleModel创建一个Raster,其中包含指定的数据类型,宽度,高度,波段数和每个波段的位数。static WritableRastercreatePackedRaster(DataBuffer dataBuffer, int w, int h, int scanlineStride, int[] bandMasks, Point location)基于SinglePixelPackedSampleModel创建一个Raster,其中包含指定的DataBuffer,width,height,scanline stride和band mask。static WritableRastercreatePackedRaster(DataBuffer dataBuffer, int w, int h, int bitsPerPixel, Point location)基于MultiPixelPackedSampleModel创建一个Raster,其中包含指定的DataBuffer,width,height和每像素位数。static RastercreateRaster(SampleModel sm, DataBuffer db, Point location)使用指定的SampleModel和DataBuffer创建Raster。RastercreateTranslatedChild(int childMinX, int childMinY)创建一个与此相同大小的Raster,SampleModel和DataBuffer,但具有不同的位置。static WritableRastercreateWritableRaster(SampleModel sm, DataBuffer db, Point location)使用指定的SampleModel和DataBuffer创建WritableRaster。static WritableRastercreateWritableRaster(SampleModel sm, Point location)使用指定的SampleModel创建WritableRaster。RectanglegetBounds()返回此Raster的边界Rectangle。DataBuffergetDataBuffer()返回与此Raster关联的DataBuffer。ObjectgetDataElements(int x, int y, int w, int h, Object outData)返回TransferType类型的基本数组中指定矩形像素的像素数据。ObjectgetDataElements(int x, int y, Object outData)返回TransferType类型的基本数组中单个像素的数据。intgetHeight()返回Raster的高度(以像素为单位)。intgetMinX()返回Raster的最小有效X坐标。intgetMinY()返回Raster的最小有效Y坐标。intgetNumBands()返回此Raster中的band数(每个像素的样本数)。intgetNumDataElements()返回通过getDataElements和setDataElements方法传输一个像素所需的数据元素数。RastergetParent()返回此Raster的父Raster(如果有)或null。double[]getPixel(int x, int y, double[] dArray)返回指定像素的double数组中的样本。float[]getPixel(int x, int y, float[] fArray)返回指定像素的float数组中的样本。int[]getPixel(int x, int y, int[] iArray)返回指定像素的int数组中的样本。double[]getPixels(int x, int y, int w, int h, double[] dArray)返回一个double数组,其中包含像素矩形的所有样本,每个数组元素一个样本。float[]getPixels(int x, int y, int w, int h, float[] fArray)返回一个float数组,其中包含像素矩形的所有样本,每个数组元素一个样本。int[]getPixels(int x, int y, int w, int h, int[] iArray)返回一个int数组,其中包含像素矩形的所有样本,每个数组元素一个样本。intgetSample(int x, int y, int b)将位于(x,y)的像素的指定band中的样本返回为int。doublegetSampleDouble(int x, int y, int b)将位于(x,y)的像素的指定波段中的样本返回为double。floatgetSampleFloat(int x, int y, int b)将位于(x,y)的像素的指定band中的样本返回为float。SampleModelgetSampleModel()返回描述图像数据布局的SampleModel。intgetSampleModelTranslateX()返回从SampleModel坐标系到Raster坐标系的X平移。intgetSampleModelTranslateY()返回从SampleModel坐标系到Raster坐标系的Y平移。double[]getSamples(int x, int y, int w, int h, int b, double[] dArray)返回双精度数组中指定矩形像素的指定波段的样本,每个数组元素一个样本。float[]getSamples(int x, int y, int w, int h, int b, float[] fArray)返回float数组中指定矩形像素的指定band的样本,每个数组元素一个样本。int[]getSamples(int x, int y, int w, int h, int b, int[] iArray)返回int数组中指定矩形像素的指定band的样本,每个数组元素一个样本。intgetTransferType()返回用于通过getDataElements和setDataElements方法传输像素的TransferType。intgetWidth()返回Raster的宽度(以像素为单位)。
-
-
-
字段详细信息
-
sampleModel
protected SampleModel sampleModel
SampleModel描述了此Raster中的像素如何存储在DataBuffer中。
-
dataBuffer
protected DataBuffer dataBuffer
存储图像数据的DataBuffer。
-
minX
protected int minX
此Raster左上角像素的X坐标。
-
minY
protected int minY
此Raster左上角像素的Y坐标。
-
width
protected int width
此光栅的宽度。
-
height
protected int height
这个光栅的高度。
-
sampleModelTranslateX
protected int sampleModelTranslateX
从Raster的SampleModel的坐标空间到Raster的坐标空间的X平移。
-
sampleModelTranslateY
protected int sampleModelTranslateY
从Raster的SampleModel的坐标空间到Raster的坐标空间的Y平移。
-
numBands
protected int numBands
栅格中的波段数。
-
numDataElements
protected int numDataElements
每个像素的DataBuffer数据元素的数量。
-
parent
protected Raster parent
此Raster的父级,或null。
-
-
构造方法详细信息
-
Raster
protected Raster(SampleModel sampleModel, Point origin)
使用给定的SampleModel构造一个Raster。 Raster的左上角是原点,它与SampleModel的大小相同。 将自动创建足以描述Raster的DataBuffer。- 参数
-
sampleModel- 指定布局的SampleModel -
origin- 指定原点的点 - 异常
-
RasterFormatException- 如果计算origin.x + sampleModel.getWidth()或origin.y + sampleModel.getHeight()导致整数溢出 -
NullPointerException-sampleModel或origin为空
-
Raster
protected Raster(SampleModel sampleModel, DataBuffer dataBuffer, Point origin)
使用给定的SampleModel和DataBuffer构造一个Raster。 Raster的左上角是原点,它与SampleModel的大小相同。 DataBuffer未初始化,必须与SampleModel兼容。- 参数
-
sampleModel- 指定布局的SampleModel -
dataBuffer- 包含图像数据的DataBuffer -
origin- 指定原点的Point - 异常
-
RasterFormatException- 如果计算origin.x + sampleModel.getWidth()或origin.y + sampleModel.getHeight()导致整数溢出 -
NullPointerException-sampleModel或origin为空
-
Raster
protected Raster(SampleModel sampleModel, DataBuffer dataBuffer, Rectangle aRegion, Point sampleModelTranslate, Raster parent)
使用给定的SampleModel,DataBuffer和parent构造一个Raster。 aRegion指定新Raster的边界矩形。 当转换为基本Raster的坐标系时,基本Raster必须包含aRegion。 (基本Raster是Raster的祖先,没有父级。)sampleModelTranslate指定新Raster的sampleModelTranslateX和sampleModelTranslateY值。 请注意,此构造函数通常应由其他构造函数或create方法调用,不应直接使用。- 参数
-
sampleModel- 指定布局的SampleModel -
dataBuffer- 包含图像数据的DataBuffer -
aRegion- 指定图像区域的矩形 -
sampleModelTranslate- 指定从SampleModel到Raster坐标的转换的Point -
parent- 此栅格的父级(如果有) - 异常
-
NullPointerException-如果任何sampleModel,dataBuffer,aRegion或sampleModelTranslate为null -
RasterFormatException- 如果aRegion宽度或高度小于或等于零,或计算aRegion.x + aRegion.width或aRegion.y + aRegion.height导致整数溢出
-
-
方法详细信息
-
createInterleavedRaster
public static WritableRaster createInterleavedRaster(int dataType, int w, int h, int bands, Point location)
基于PixelInterleavedSampleModel创建一个Raster,其中包含指定的数据类型,宽度,高度和band数。Raster的左上角由location参数给出。 如果location为null,将使用(0,0)。 dataType参数应该是DataBuffer类中定义的枚举值之一。
请注意,不支持交错
DataBuffer.TYPE_INT栅格。 要创建类型为DataBuffer.TYPE_INT的1波段光栅,请使用Raster.createPackedRaster()。目前支持的唯一数据类型是TYPE_BYTE和TYPE_USHORT。
- 参数
-
dataType- 用于存储样本的数据类型 -
w- 图像数据的宽度(以像素为单位) -
h- 图像数据的像素高度 -
bands- 频段数 -
location-Raster - 结果
- 具有指定数据类型,宽度,高度和波段数的WritableRaster对象。
- 异常
-
RasterFormatException- 如果w或h小于或等于零,或计算location.x + w或location.y + h导致整数溢出
-
createInterleavedRaster
public static WritableRaster createInterleavedRaster(int dataType, int w, int h, int scanlineStride, int pixelStride, int[] bandOffsets, Point location)
基于PixelInterleavedSampleModel创建一个Raster,其中包含指定的数据类型,宽度,高度,扫描行间距,像素跨度和波段偏移。 band的数量是从bandOffsets.length推断出来的。Raster的左上角由location参数给出。 如果location为null,将使用(0,0)。 dataType参数应该是DataBuffer类中定义的枚举值之一。
请注意,不支持交错
DataBuffer.TYPE_INT栅格。 要创建类型为DataBuffer.TYPE_INT的1波段光栅,请使用Raster.createPackedRaster()。目前支持的唯一数据类型是TYPE_BYTE和TYPE_USHORT。
- 参数
-
dataType- 用于存储样本的数据类型 -
w- 图像数据的宽度(以像素为单位) -
h- 图像数据的高度(以像素为单位) -
scanlineStride- 图像数据的行scanlineStride -
pixelStride- 图像数据的像素跨度 -
bandOffsets- 所有乐队的抵消 -
location-Raster - 结果
- 一个WritableRaster对象,具有指定的数据类型,宽度,高度,扫描行间距,像素跨度和带偏移。
- 异常
-
RasterFormatException- 如果w或h小于或等于零,或计算location.x + w或location.y + h导致整数溢出 -
IllegalArgumentException- 如果dataType不是受支持的数据类型之一,即DataBuffer.TYPE_BYTE或DataBuffer.TYPE_USHORT。
-
createBandedRaster
public static WritableRaster createBandedRaster(int dataType, int w, int h, int bands, Point location)
基于BandedSampleModel创建一个Raster,其中包含指定的数据类型,宽度,高度和band数。Raster的左上角由location参数给出。 如果location为null,将使用(0,0)。 dataType参数应该是DataBuffer类中定义的枚举值之一。
目前支持的唯一数据类型是TYPE_BYTE,TYPE_USHORT和TYPE_INT。
- 参数
-
dataType- 用于存储样本的数据类型 -
w- 图像数据的宽度(以像素为单位) -
h- 图像数据的高度(以像素为单位) -
bands- 频段数 -
location-Raster - 结果
- 具有指定数据类型,宽度,高度和波段数的WritableRaster对象。
- 异常
-
RasterFormatException- 如果w或h小于或等于零,或计算location.x + w或location.y + h导致整数溢出 -
ArrayIndexOutOfBoundsException- 如果bands小于1
-
createBandedRaster
public static WritableRaster createBandedRaster(int dataType, int w, int h, int scanlineStride, int[] bankIndices, int[] bandOffsets, Point location)
基于BandedSampleModel创建一个Raster,其中包含指定的数据类型,宽度,高度,扫描行间距,行索引和波段偏移。 band的数量是从bankIndices.length和bandOffsets.length推断出来的,它们必须相同。Raster的左上角由location参数给出。 dataType参数应该是DataBuffer类中定义的枚举值之一。
目前支持的唯一数据类型是TYPE_BYTE,TYPE_USHORT和TYPE_INT。
- 参数
-
dataType- 用于存储样本的数据类型 -
w- 图像数据的宽度(以像素为单位) -
h- 图像数据的高度(以像素为单位) -
scanlineStride- 图像数据的行scanlineStride -
bankIndices- 每个频段的银行指数 -
bandOffsets- 所有波段的偏移量 -
location-Raster - 结果
- 一个WritableRaster对象,具有指定的数据类型,宽度,高度,扫描行间距,银行索引和波段偏移。
- 异常
-
RasterFormatException- 如果w或h小于或等于零,或计算location.x + w或location.y + h导致整数溢出 -
IllegalArgumentException-如果dataType是不支持的数据类型,这是一个DataBuffer.TYPE_BYTE,DataBuffer.TYPE_USHORT或DataBuffer.TYPE_INT -
ArrayIndexOutOfBoundsException- 如果bankIndices或bandOffsets是null
-
createPackedRaster
public static WritableRaster createPackedRaster(int dataType, int w, int h, int[] bandMasks, Point location)
基于具有指定数据类型,宽度,高度和波段掩码的SinglePixelPackedSampleModel创建栅格。 band的数量是从bandMasks.length推断出来的。Raster的左上角由location参数给出。 如果location为null,将使用(0,0)。 dataType参数应该是DataBuffer类中定义的枚举值之一。
目前支持的唯一数据类型是TYPE_BYTE,TYPE_USHORT和TYPE_INT。
- 参数
-
dataType- 用于存储样本的数据类型 -
w- 图像数据的宽度(以像素为单位) -
h- 图像数据的高度(以像素为单位) -
bandMasks- 包含每个波段条目的数组 -
location-Raster - 结果
- 具有指定数据类型,宽度,高度和带掩码的WritableRaster对象。
- 异常
-
RasterFormatException- 如果w或h小于或等于零,或计算location.x + w或location.y + h导致整数溢出 -
IllegalArgumentException-如果dataType是不支持的数据类型,这是一个DataBuffer.TYPE_BYTE,DataBuffer.TYPE_USHORT或DataBuffer.TYPE_INT
-
createPackedRaster
public static WritableRaster createPackedRaster(int dataType, int w, int h, int bands, int bitsPerBand, Point location)
基于打包的SampleModel创建一个Raster,其中包含指定的数据类型,宽度,高度,波段数和每个波段的位数。 如果band的数量是1,则SampleModel将是MultiPixelPackedSampleModel。如果band的数量大于1,则SampleModel将是SinglePixelPackedSampleModel,每个band具有bitsPerBand位。 在任何一种情况下,都必须满足相应SampleModel对dataType和bitsPerBand的要求。
Raster的左上角由location参数给出。 如果location为null,将使用(0,0)。 dataType参数应该是DataBuffer类中定义的枚举值之一。
目前支持的唯一数据类型是TYPE_BYTE,TYPE_USHORT和TYPE_INT。
- 参数
-
dataType- 用于存储样本的数据类型 -
w- 图像数据的宽度(以像素为单位) -
h- 图像数据的高度(以像素为单位) -
bands- 频段数 -
bitsPerBand- 每个频段的比特数 -
location-Raster - 结果
- 一个WritableRaster对象,具有指定的数据类型,宽度,高度,带数和每个带的位数。
- 异常
-
RasterFormatException- 如果w或h小于或等于零,或计算location.x + w或location.y + h导致整数溢出 -
IllegalArgumentException- 如果bitsPerBand和bands大于dataType所持有的dataType -
IllegalArgumentException- 如果bitsPerBand或bands不大于零 -
IllegalArgumentException-如果dataType是不支持的数据类型,这是一个DataBuffer.TYPE_BYTE,DataBuffer.TYPE_USHORT或DataBuffer.TYPE_INT
-
createInterleavedRaster
public static WritableRaster createInterleavedRaster(DataBuffer dataBuffer, int w, int h, int scanlineStride, int pixelStride, int[] bandOffsets, Point location)
基于PixelInterleavedSampleModel创建一个Raster,其中包含指定的DataBuffer,width,height,scanline stride,pixel stride和band offset。 band的数量是从bandOffsets.length推断出来的。 Raster的左上角由location参数给出。 如果location为null,将使用(0,0)。请注意,不支持交错
DataBuffer.TYPE_INT栅格。 要创建类型为DataBuffer.TYPE_INT的1波段光栅,请使用Raster.createPackedRaster()。- 参数
-
dataBuffer- 包含图像数据的DataBuffer -
w- 图像数据的宽度(以像素为单位) -
h- 图像数据的高度(以像素为单位) -
scanlineStride- 图像数据的行scanlineStride -
pixelStride- 图像数据的像素跨度 -
bandOffsets- 所有乐队的抵消 -
location-Raster - 结果
-
一个WritableRaster对象,具有指定的
DataBuffer,宽度,高度,扫描行间距,像素跨度和带偏移。 - 异常
-
RasterFormatException- 如果w或h小于或等于零,或计算location.x + w或location.y + h导致整数溢出 -
IllegalArgumentException-如果dataType是不支持的数据类型,这是一个DataBuffer.TYPE_BYTE,DataBuffer.TYPE_USHORT -
RasterFormatException- 如果dataBuffer有多个银行。 -
NullPointerException- 如果dataBuffer为空
-
createBandedRaster
public static WritableRaster createBandedRaster(DataBuffer dataBuffer, int w, int h, int scanlineStride, int[] bankIndices, int[] bandOffsets, Point location)
基于BandedSampleModel创建一个Raster,其中包含指定的DataBuffer,width,height,scanline stride,bank indices和band offset。 band的数量是从bankIndices.length和bandOffsets.length推断出来的,它们必须相同。 Raster的左上角由location参数给出。 如果location为null,将使用(0,0)。- 参数
-
dataBuffer- 包含图像数据的DataBuffer -
w- 图像数据的宽度(以像素为单位) -
h- 图像数据的高度(以像素为单位) -
scanlineStride- 图像数据的行scanlineStride -
bankIndices- 每个频段的银行指数 -
bandOffsets- 所有乐队的抵消 -
location-Raster - 结果
-
一个WritableRaster对象,具有指定的
DataBuffer,宽度,高度,扫描行间距,行索引和波段偏移。 - 异常
-
RasterFormatException- 如果w或h小于或等于零,或计算location.x + w或location.y + h导致整数溢出 -
IllegalArgumentException-如果dataType是不支持的数据类型,这是一个DataBuffer.TYPE_BYTE,DataBuffer.TYPE_USHORT或DataBuffer.TYPE_INT -
NullPointerException- 如果dataBuffer为空
-
createPackedRaster
public static WritableRaster createPackedRaster(DataBuffer dataBuffer, int w, int h, int scanlineStride, int[] bandMasks, Point location)
基于SinglePixelPackedSampleModel创建一个Raster,其中包含指定的DataBuffer,width,height,scanline stride和band mask。 band的数量是从bandMasks.length推断出来的。 Raster的左上角由location参数给出。 如果location为null,将使用(0,0)。- 参数
-
dataBuffer- 包含图像数据的DataBuffer -
w- 图像数据的宽度(以像素为单位) -
h- 图像数据的高度(以像素为单位) -
scanlineStride- 图像数据的行scanlineStride -
bandMasks- 包含每个波段条目的数组 -
location-Raster - 结果
-
具有指定的
DataBuffer,宽度,高度,扫描行间距和带蒙版的WritableRaster对象。 - 异常
-
RasterFormatException- 如果w或h小于或等于零,或计算location.x + w或location.y + h导致整数溢出 -
IllegalArgumentException-如果dataType是不支持的数据类型,这是一个DataBuffer.TYPE_BYTE,DataBuffer.TYPE_USHORT或DataBuffer.TYPE_INT -
RasterFormatException- 如果dataBuffer有多个银行。 -
NullPointerException- 如果dataBuffer为空
-
createPackedRaster
public static WritableRaster createPackedRaster(DataBuffer dataBuffer, int w, int h, int bitsPerPixel, Point location)
基于MultiPixelPackedSampleModel创建一个Raster,其中包含指定的DataBuffer,width,height和每像素位数。 Raster的左上角由location参数给出。 如果location为null,将使用(0,0)。- 参数
-
dataBuffer- 包含图像数据的DataBuffer -
w- 图像数据的宽度(以像素为单位) -
h- 图像数据的高度(以像素为单位) -
bitsPerPixel- 每个像素的位数 -
location-Raster - 结果
-
一个WritableRaster对象,具有指定的
DataBuffer,宽度,高度和每像素位数。 - 异常
-
RasterFormatException- 如果w或h小于或等于零,或计算location.x + w或location.y + h导致整数溢出 -
IllegalArgumentException-如果dataType是不支持的数据类型,这是一个DataBuffer.TYPE_BYTE,DataBuffer.TYPE_USHORT或DataBuffer.TYPE_INT -
RasterFormatException- 如果dataBuffer有多个银行。 -
NullPointerException- 如果dataBuffer为空
-
createRaster
public static Raster createRaster(SampleModel sm, DataBuffer db, Point location)
使用指定的SampleModel和DataBuffer创建Raster。 Raster的左上角由location参数给出。 如果location为null,将使用(0,0)。- 参数
-
sm- 指定的SampleModel -
db- 指定的DataBuffer -
location-Raster - 结果
-
一个
Raster带有指定SampleModel,DataBuffer,和位置。 - 异常
-
RasterFormatException- 如果计算location.x + sm.getWidth()或location.y + sm.getHeight()导致整数溢出 -
RasterFormatException- 如果db具有多个库,则sm是PixelInterleavedSampleModel,SinglePixelPackedSampleModel或MultiPixelPackedSampleModel。 -
NullPointerException- 如果SampleModel或DataBuffer为null
-
createWritableRaster
public static WritableRaster createWritableRaster(SampleModel sm, Point location)
使用指定的SampleModel创建WritableRaster。 Raster的左上角由location参数给出。 如果location为null,将使用(0,0)。- 参数
-
sm- 指定的SampleModel -
location-WritableRaster - 结果
-
a
WritableRaster具有指定的SampleModel和位置。 - 异常
-
RasterFormatException- 如果计算location.x + sm.getWidth()或location.y + sm.getHeight()导致整数溢出
-
createWritableRaster
public static WritableRaster createWritableRaster(SampleModel sm, DataBuffer db, Point location)
使用指定的SampleModel和DataBuffer创建WritableRaster。 Raster的左上角由location参数给出。 如果location为null,将使用(0,0)。- 参数
-
sm- 指定的SampleModel -
db- 指定的DataBuffer -
location-WritableRaster - 结果
-
一个
WritableRaster带有指定SampleModel,DataBuffer,和位置。 - 异常
-
RasterFormatException- 如果计算location.x + sm.getWidth()或location.y + sm.getHeight()导致整数溢出 -
RasterFormatException- 如果db具有多个库,则sm是PixelInterleavedSampleModel,SinglePixelPackedSampleModel或MultiPixelPackedSampleModel。 -
NullPointerException- 如果SampleModel或DataBuffer为null
-
getParent
public Raster getParent()
返回此Raster的父Raster(如果有)或null。- 结果
-
父Raster或
null。
-
getSampleModelTranslateX
public final int getSampleModelTranslateX()
返回从SampleModel坐标系到Raster坐标系的X平移。 要将像素的X坐标从栅格坐标系转换为SampleModel坐标系,必须减去该值。- 结果
- 从Raster的SampleModel的坐标空间到Raster的坐标空间的X平移。
-
getSampleModelTranslateY
public final int getSampleModelTranslateY()
返回从SampleModel坐标系到Raster坐标系的Y平移。 要将像素的Y坐标从光栅坐标系转换为SampleModel坐标系,必须减去此值。- 结果
- 从Raster的SampleModel的坐标空间到Raster的坐标空间的Y平移。
-
createCompatibleWritableRaster
public WritableRaster createCompatibleWritableRaster()
使用相同的SampleModel和新的初始化DataBuffer创建与此Raster大小相同的兼容WritableRaster。- 结果
-
兼容的
WritableRaster具有相同的样本模型和新的数据缓冲区。
-
createCompatibleWritableRaster
public WritableRaster createCompatibleWritableRaster(int w, int h)
创建具有指定大小的兼容WritableRaster,新的SampleModel和新初始化的DataBuffer。- 参数
-
w- 新WritableRaster的指定宽度 -
h- 新WritableRaster的指定高度 - 结果
-
具有指定大小的兼容
WritableRaster以及新的样本模型和数据缓冲区。 - 异常
-
RasterFormatException- 如果宽度或高度小于或等于零。
-
createCompatibleWritableRaster
public WritableRaster createCompatibleWritableRaster(Rectangle rect)
创建兼容的WritableRaster,其中包含由rect指定的位置(minX,minY)和大小(宽度,高度),新的SampleModel和新的初始化DataBuffer。- 参数
-
rect-一个Rectangle指定的大小和位置WritableRaster - 结果
-
具有指定大小和位置的兼容
WritableRaster以及新的样本模型和数据缓冲区。 - 异常
-
RasterFormatException- 如果rect宽度或高度小于或等于零,或计算rect.x + rect.width或rect.y + rect.height导致整数溢出 -
NullPointerException- 如果rect为空
-
createCompatibleWritableRaster
public WritableRaster createCompatibleWritableRaster(int x, int y, int w, int h)
创建一个兼容的WritableRaster,它具有指定的位置(minX,minY)和大小(宽度,高度),一个新的SampleModel和一个新的初始化DataBuffer。- 参数
-
x-在X中的左上角坐标WritableRaster -
y-的Y的左上角坐标WritableRaster -
w- 指定的宽度WritableRaster -
h-在指定高度WritableRaster - 结果
-
具有指定大小和位置的兼容
WritableRaster以及新的样本模型和数据缓冲区。 - 异常
-
RasterFormatException- 如果w或h小于或等于零,或计算x + w或y + h导致整数溢出
-
createTranslatedChild
public Raster createTranslatedChild(int childMinX, int childMinY)
创建一个与此相同大小的Raster,SampleModel和DataBuffer,但具有不同的位置。 新的Raster将拥有对当前Raster的引用,可通过其getParent()方法访问。- 参数
-
childMinX- 新Raster左上角的X坐标 -
childMinY- 新Raster左上角的Y坐标 - 结果
-
新
Raster相同大小,SampleModel和DataBuffer与此Raster,但与指定的位置。 - 异常
-
RasterFormatException- 如果计算childMinX + this.getWidth()或childMinY + this.getHeight()导致整数溢出
-
createChild
public Raster createChild(int parentX, int parentY, int width, int height, int childMinX, int childMinY, int[] bandList)
返回一个新的Raster,它共享此Raster的DataBuffer的全部或部分内容。 新的Raster将拥有对当前Raster的引用,可通过其getParent()方法访问。parentX,parentY,width和height参数在此Raster的坐标空间中形成一个Rectangle,指示要共享的像素区域。 如果此Rectangle未包含在当前Raster的边界内,则会引发错误。
新的Raster可以另外转换为平面的不同坐标系,而不是当前Raster使用的坐标系。 childMinX和childMinY参数给出返回的Raster的左上角像素的新(x,y)坐标; 新Raster中的坐标(childMinX,childMinY)将映射到与当前Raster中坐标(parentX,parentY)相同的像素。
可以通过bandList参数将新Raster定义为仅包含当前Raster的频带的子集,可能重新排序。 如果bandList为null,则将其包含在当前顺序中的当前Raster的所有band。
要创建包含当前Raster的子区域但共享其坐标系和波段的新Raster,应调用此方法,其中childMinX等于parentX,childMinY等于parentY,bandList等于null。
- 参数
-
parentX- 此Raster坐标中左上角的X坐标 -
parentY- 此Raster坐标中左上角的Y坐标 -
width- 以(parentX,parentY)开头的区域宽度 -
height- 从(parentX,parentY)开始的区域的高度。 -
childMinX- 返回的Raster左上角的X坐标 -
childMinY- 返回的Raster左上角的Y坐标 -
bandList- 波段索引数组,或null以使用所有波段 - 结果
-
一个新的
Raster。 - 异常
-
RasterFormatException- 如果指定的子区域位于栅格边界之外。 -
RasterFormatException-如果width或height小于或等于0,或者计算任何的parentX + width,parentY + height,childMinX + width,或childMinY + height导致整数溢出
-
getBounds
public Rectangle getBounds()
返回此Raster的边界Rectangle。 此函数返回与getMinX / MinY / Width / Height相同的信息。- 结果
-
此
Raster的边界框。
-
getMinX
public final int getMinX()
返回Raster的最小有效X坐标。- 结果
-
这个
Raster的最小x坐标。
-
getMinY
public final int getMinY()
返回Raster的最小有效Y坐标。- 结果
-
这个
Raster的最小y坐标。
-
getWidth
public final int getWidth()
返回Raster的宽度(以像素为单位)。- 结果
-
这个宽度
Raster。
-
getHeight
public final int getHeight()
返回Raster的高度(以像素为单位)。- 结果
-
这个高度
Raster。
-
getNumBands
public final int getNumBands()
返回此Raster中的band数(每个像素的样本数)。- 结果
-
这个
Raster的乐队数量。
-
getNumDataElements
public final int getNumDataElements()
返回通过getDataElements和setDataElements方法传输一个像素所需的数据元素数。 当通过这些方法传输像素时,它们可以以打包或解包格式传输,具体取决于底层SampleModel的实现。 使用这些方法,像素作为getTransferType()给出的基本类型的getNumDataElements()元素数组传输。 TransferType可能与DataBuffer的存储数据类型相同或不同。- 结果
- 数据元素的数量。
-
getTransferType
public final int getTransferType()
返回用于通过getDataElements和setDataElements方法传输像素的TransferType。 当通过这些方法传输像素时,它们可以以打包或解包格式传输,具体取决于底层SampleModel的实现。 使用这些方法,像素作为getTransferType()给出的基本类型的getNumDataElements()元素数组传输。 TransferType可能与DataBuffer的存储数据类型相同或不同。 TransferType将是DataBuffer中定义的类型之一。- 结果
- 这种转移类型。
-
getDataBuffer
public DataBuffer getDataBuffer()
返回与此Raster关联的DataBuffer。- 结果
-
DataBuffer的Raster。
-
getSampleModel
public SampleModel getSampleModel()
返回描述图像数据布局的SampleModel。- 结果
-
SampleModel的Raster。
-
getDataElements
public Object getDataElements(int x, int y, Object outData)
返回TransferType类型的基本数组中单个像素的数据。 对于Java 2D(tm)API支持的图像数据,这将是DataBuffer.TYPE_BYTE,DataBuffer.TYPE_USHORT,DataBuffer.TYPE_INT,DataBuffer.TYPE_SHORT,DataBuffer.TYPE_FLOAT或DataBuffer.TYPE_DOUBLE之一。 数据可以以打包格式返回,从而提高数据传输的效率。 如果坐标不在边界内,则可能抛出ArrayIndexOutOfBoundsException。 但是,不保证显式边界检查。 如果输入对象为非null并且引用除TransferType数组之外的任何内容,则抛出ClassCastException。- 参数
-
x- 像素位置的X坐标 -
y- 像素位置的Y坐标 -
outData- 对getTransferType()和length getNumDataElements()定义的类型数组的对象引用。 如果为null,则将分配适当类型和大小的数组 - 结果
- 对由getTransferType()定义的类型数组的对象引用,其中包含请求的像素数据。
- 异常
-
ArrayIndexOutOfBoundsException- 如果坐标不在边界内,或者outData太小而无法保持输出。 - 另请参见:
-
SampleModel.getDataElements(int, int, Object, DataBuffer)
-
getDataElements
public Object getDataElements(int x, int y, int w, int h, Object outData)
返回TransferType类型的基本数组中指定矩形像素的像素数据。 对于Java 2D API支持的图像数据,这将是DataBuffer.TYPE_BYTE,DataBuffer.TYPE_USHORT,DataBuffer.TYPE_INT,DataBuffer.TYPE_SHORT,DataBuffer.TYPE_FLOAT或DataBuffer.TYPE_DOUBLE之一。 数据可以以打包格式返回,从而提高数据传输的效率。 如果坐标不在边界内,则可能抛出ArrayIndexOutOfBoundsException。 但是,不保证显式边界检查。 如果输入对象为非null并且引用除TransferType数组之外的任何内容,则抛出ClassCastException。- 参数
-
x- 左上角像素位置的X坐标 -
y- 左上角像素位置的Y坐标 -
w- 像素矩形的宽度 -
h- 像素矩形的高度 -
outData- 对getTransferType()和length w * h * getNumDataElements()定义的类型数组的对象引用。 如果为null,则将分配适当类型和大小的数组。 - 结果
- 对由getTransferType()定义的类型数组的对象引用,其中包含请求的像素数据。
- 异常
-
ArrayIndexOutOfBoundsException- 如果坐标不在边界内,或者outData太小而无法保持输出。 - 另请参见:
-
SampleModel.getDataElements(int, int, int, int, Object, DataBuffer)
-
getPixel
public int[] getPixel(int x, int y, int[] iArray)返回指定像素的int数组中的样本。 如果坐标不在边界内,则可能抛出ArrayIndexOutOfBoundsException。 但是,不保证显式边界检查。- 参数
-
x- 像素位置的X坐标 -
y- 像素位置的Y坐标 -
iArray- 可选的预分配int数组 - 结果
- 指定像素的样本。
- 异常
-
ArrayIndexOutOfBoundsException- 如果坐标不在边界内,或者iArray太小而无法容纳输出。
-
getPixel
public float[] getPixel(int x, int y, float[] fArray)返回指定像素的float数组中的样本。 如果坐标不在边界内,则可能抛出ArrayIndexOutOfBoundsException。 但是,不保证显式边界检查。- 参数
-
x- 像素位置的X坐标 -
y- 像素位置的Y坐标 -
fArray- 可选的预分配浮点数组 - 结果
- 指定像素的样本。
- 异常
-
ArrayIndexOutOfBoundsException- 如果坐标不在边界内,或者fArray太小而无法保持输出。
-
getPixel
public double[] getPixel(int x, int y, double[] dArray)返回指定像素的double数组中的样本。 如果坐标不在边界内,则可能抛出ArrayIndexOutOfBoundsException。 但是,不保证显式边界检查。- 参数
-
x- 像素位置的X坐标 -
y- 像素位置的Y坐标 -
dArray- 可选的预分配双数组 - 结果
- 指定像素的样本。
- 异常
-
ArrayIndexOutOfBoundsException- 如果坐标不在边界内,或者ArrayIndexOutOfBoundsException太小而无法保持输出。
-
getPixels
public int[] getPixels(int x, int y, int w, int h, int[] iArray)返回一个int数组,其中包含像素矩形的所有样本,每个数组元素一个样本。 如果坐标不在边界内,则可能抛出ArrayIndexOutOfBoundsException。 但是,不保证显式边界检查。- 参数
-
x- 左上角像素位置的X坐标 -
y- 左上角像素位置的Y坐标 -
w- 像素矩形的宽度 -
h- 像素矩形的高度 -
iArray- 可选的预分配int数组 - 结果
- 指定矩形像素的样本。
- 异常
-
ArrayIndexOutOfBoundsException- 如果坐标不在边界内,或者iArray太小而无法保持输出。
-
getPixels
public float[] getPixels(int x, int y, int w, int h, float[] fArray)返回一个float数组,其中包含像素矩形的所有样本,每个数组元素一个样本。 如果坐标不在边界内,则可能抛出ArrayIndexOutOfBoundsException。 但是,不保证显式边界检查。- 参数
-
x- 像素位置的X坐标 -
y- 像素位置的Y坐标 -
w- 像素矩形的宽度 -
h- 像素矩形的高度 -
fArray- 可选的预分配浮点数组 - 结果
- 指定矩形像素的样本。
- 异常
-
ArrayIndexOutOfBoundsException- 如果坐标不在边界内,或者fArray太小而无法保持输出。
-
getPixels
public double[] getPixels(int x, int y, int w, int h, double[] dArray)返回一个double数组,其中包含像素矩形的所有样本,每个数组元素一个样本。 如果坐标不在边界内,则可能抛出ArrayIndexOutOfBoundsException。 但是,不保证显式边界检查。- 参数
-
x- 左上角像素位置的X坐标 -
y- 左上角像素位置的Y坐标 -
w- 像素矩形的宽度 -
h- 像素矩形的高度 -
dArray- 可选的预分配双数组 - 结果
- 指定矩形像素的样本。
- 异常
-
ArrayIndexOutOfBoundsException- 如果坐标不在边界内,或者ArrayIndexOutOfBoundsException太小而无法容纳输出。
-
getSample
public int getSample(int x, int y, int b)将位于(x,y)的像素的指定band中的样本返回为int。 如果坐标不在边界内,则可能抛出ArrayIndexOutOfBoundsException。 但是,不保证显式边界检查。- 参数
-
x- 像素位置的X坐标 -
y- 像素位置的Y坐标 -
b- 乐队返回 - 结果
- 指定坐标中像素的指定波段中的样本。
- 异常
-
ArrayIndexOutOfBoundsException- 如果坐标或波段索引不在边界内。
-
getSampleFloat
public float getSampleFloat(int x, int y, int b)将位于(x,y)的像素的指定band中的样本返回为float。 如果坐标不在边界内,则可能抛出ArrayIndexOutOfBoundsException。 但是,不保证显式边界检查。- 参数
-
x- 像素位置的X坐标 -
y- 像素位置的Y坐标 -
b- 乐队返回 - 结果
- 指定坐标中像素的指定波段中的样本。
- 异常
-
ArrayIndexOutOfBoundsException- 如果坐标或波段索引不在边界内。
-
getSampleDouble
public double getSampleDouble(int x, int y, int b)将位于(x,y)的像素的指定波段中的样本返回为double。 如果坐标不在边界内,则可能抛出ArrayIndexOutOfBoundsException。 但是,不保证显式边界检查。- 参数
-
x- 像素位置的X坐标 -
y- 像素位置的Y坐标 -
b- 乐队返回 - 结果
- 指定坐标中像素的指定波段中的样本。
- 异常
-
ArrayIndexOutOfBoundsException- 如果坐标或波段索引不在边界内。
-
getSamples
public int[] getSamples(int x, int y, int w, int h, int b, int[] iArray)返回int数组中指定矩形像素的指定band的样本,每个数组元素一个样本。 如果坐标不在边界内,则可能抛出ArrayIndexOutOfBoundsException。 但是,不保证显式边界检查。- 参数
-
x- 左上角像素位置的X坐标 -
y- 左上角像素位置的Y坐标 -
w- 像素矩形的宽度 -
h- 像素矩形的高度 -
b- 乐队返回 -
iArray- 可选的预分配int数组 - 结果
- 指定像素矩形的指定波段的样本。
- 异常
-
ArrayIndexOutOfBoundsException- 如果坐标或波段索引不在边界内,或者iArray太小而无法保持输出。
-
getSamples
public float[] getSamples(int x, int y, int w, int h, int b, float[] fArray)返回float数组中指定矩形像素的指定band的样本,每个数组元素一个样本。 如果坐标不在边界内,则可能抛出ArrayIndexOutOfBoundsException。 但是,不保证显式边界检查。- 参数
-
x- 左上角像素位置的X坐标 -
y- 左上角像素位置的Y坐标 -
w- 像素矩形的宽度 -
h- 像素矩形的高度 -
b- 要返回的乐队 -
fArray- 可选的预分配浮点数组 - 结果
- 指定像素矩形的指定波段的样本。
- 异常
-
ArrayIndexOutOfBoundsException- 如果坐标或波段索引不在边界内,或者fArray太小而无法保持输出。
-
getSamples
public double[] getSamples(int x, int y, int w, int h, int b, double[] dArray)返回双精度数组中指定矩形像素的指定波段的样本,每个数组元素一个样本。 如果坐标不在边界内,则可能抛出ArrayIndexOutOfBoundsException。 但是,不保证显式边界检查。- 参数
-
x- 左上角像素位置的X坐标 -
y- 左上角像素位置的Y坐标 -
w- 像素矩形的宽度 -
h- 像素矩形的高度 -
b- 乐队返回 -
dArray- 可选的预分配双数组 - 结果
- 指定像素矩形的指定波段的样本。
- 异常
-
ArrayIndexOutOfBoundsException- 如果坐标或波段索引不在边界内,或者dArray太小而无法保持输出。
-
-