本文整理汇总了Java中java.awt.image.DataBufferByte.getOffsets方法的典型用法代码示例。如果您正苦于以下问题:Java DataBufferByte.getOffsets方法的具体用法?Java DataBufferByte.getOffsets怎么用?Java DataBufferByte.getOffsets使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.image.DataBufferByte
的用法示例。
在下文中一共展示了DataBufferByte.getOffsets方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ByteBandedRaster
import java.awt.image.DataBufferByte; //导入方法依赖的package包/类
/**
* Constructs a ByteBandedRaster with the given sampleModel,
* DataBuffer, and parent. DataBuffer must be a DataBufferShort and
* SampleModel must be of type BandedSampleModel.
* When translated into the base Raster's
* coordinate system, aRegion must be contained by the base Raster.
* Origin is the coordinate in the new Raster's coordinate system of
* the origin of the base Raster. (The base Raster is the Raster's
* ancestor which has no parent.)
*
* Note that this constructor should generally be called by other
* constructors or create methods, it should not be used directly.
* @param sampleModel The SampleModel that specifies the layout.
* @param dataBuffer The DataBufferShort that contains the image data.
* @param aRegion The Rectangle that specifies the image area.
* @param origin The Point that specifies the origin.
* @param parent The parent (if any) of this raster.
*/
public ByteBandedRaster(SampleModel sampleModel,
DataBuffer dataBuffer,
Rectangle aRegion,
Point origin,
ByteBandedRaster parent) {
super(sampleModel, dataBuffer, aRegion, origin, parent);
this.maxX = minX + width;
this.maxY = minY + height;
if (!(dataBuffer instanceof DataBufferByte)) {
throw new RasterFormatException("ByteBandedRaster must have" +
"byte DataBuffers");
}
DataBufferByte dbb = (DataBufferByte)dataBuffer;
if (sampleModel instanceof BandedSampleModel) {
BandedSampleModel bsm = (BandedSampleModel)sampleModel;
this.scanlineStride = bsm.getScanlineStride();
int bankIndices[] = bsm.getBankIndices();
int bandOffsets[] = bsm.getBandOffsets();
int dOffsets[] = dbb.getOffsets();
dataOffsets = new int[bankIndices.length];
data = new byte[bankIndices.length][];
int xOffset = aRegion.x - origin.x;
int yOffset = aRegion.y - origin.y;
for (int i = 0; i < bankIndices.length; i++) {
data[i] = stealData(dbb, bankIndices[i]);
dataOffsets[i] = dOffsets[bankIndices[i]] +
xOffset + yOffset*scanlineStride + bandOffsets[i];
}
} else {
throw new RasterFormatException("ByteBandedRasters must have"+
"BandedSampleModels");
}
verify();
}
示例2: ByteBandedRaster
import java.awt.image.DataBufferByte; //导入方法依赖的package包/类
/**
* Constructs a ByteBandedRaster with the given sampleModel,
* DataBuffer, and parent. DataBuffer must be a DataBufferShort and
* SampleModel must be of type BandedSampleModel.
* When translated into the base Raster's
* coordinate system, aRegion must be contained by the base Raster.
* Origin is the coordinate in the new Raster's coordinate system of
* the origin of the base Raster. (The base Raster is the Raster's
* ancestor which has no parent.)
*
* Note that this constructor should generally be called by other
* constructors or create methods, it should not be used directly.
* @param sampleModel The SampleModel that specifies the layout.
* @param dataBuffer The DataBufferByte that contains the image data.
* @param aRegion The Rectangle that specifies the image area.
* @param origin The Point that specifies the origin.
* @param parent The parent (if any) of this raster.
*/
public ByteBandedRaster(SampleModel sampleModel,
DataBufferByte dataBuffer,
Rectangle aRegion,
Point origin,
ByteBandedRaster parent)
{
super(sampleModel, dataBuffer, aRegion, origin, parent);
this.maxX = minX + width;
this.maxY = minY + height;
if (sampleModel instanceof BandedSampleModel) {
BandedSampleModel bsm = (BandedSampleModel)sampleModel;
this.scanlineStride = bsm.getScanlineStride();
int bankIndices[] = bsm.getBankIndices();
int bandOffsets[] = bsm.getBandOffsets();
int dOffsets[] = dataBuffer.getOffsets();
dataOffsets = new int[bankIndices.length];
data = new byte[bankIndices.length][];
int xOffset = aRegion.x - origin.x;
int yOffset = aRegion.y - origin.y;
for (int i = 0; i < bankIndices.length; i++) {
data[i] = stealData(dataBuffer, bankIndices[i]);
dataOffsets[i] = dOffsets[bankIndices[i]] +
xOffset + yOffset*scanlineStride + bandOffsets[i];
}
} else {
throw new RasterFormatException("ByteBandedRasters must have"+
"BandedSampleModels");
}
verify();
}