本文整理匯總了Java中java.awt.image.DataBufferByte.getNumBanks方法的典型用法代碼示例。如果您正苦於以下問題:Java DataBufferByte.getNumBanks方法的具體用法?Java DataBufferByte.getNumBanks怎麽用?Java DataBufferByte.getNumBanks使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.awt.image.DataBufferByte
的用法示例。
在下文中一共展示了DataBufferByte.getNumBanks方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: BytePackedRaster
import java.awt.image.DataBufferByte; //導入方法依賴的package包/類
/**
* Constructs a BytePackedRaster with the given SampleModel,
* DataBuffer, and parent. DataBuffer must be a DataBufferByte and
* SampleModel must be of type MultiPixelPackedSampleModel.
* 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.
*
* @exception RasterFormatException if the parameters do not conform
* to requirements of this Raster type.
*/
public BytePackedRaster(SampleModel sampleModel,
DataBuffer dataBuffer,
Rectangle aRegion,
Point origin,
BytePackedRaster parent){
super(sampleModel,dataBuffer,aRegion,origin, parent);
this.maxX = minX + width;
this.maxY = minY + height;
if (!(dataBuffer instanceof DataBufferByte)) {
throw new RasterFormatException("BytePackedRasters must have" +
"byte DataBuffers");
}
DataBufferByte dbb = (DataBufferByte)dataBuffer;
this.data = stealData(dbb, 0);
if (dbb.getNumBanks() != 1) {
throw new
RasterFormatException("DataBuffer for BytePackedRasters"+
" must only have 1 bank.");
}
int dbOffset = dbb.getOffset();
if (sampleModel instanceof MultiPixelPackedSampleModel) {
MultiPixelPackedSampleModel mppsm =
(MultiPixelPackedSampleModel)sampleModel;
this.type = IntegerComponentRaster.TYPE_BYTE_BINARY_SAMPLES;
pixelBitStride = mppsm.getPixelBitStride();
if (pixelBitStride != 1 &&
pixelBitStride != 2 &&
pixelBitStride != 4) {
throw new RasterFormatException
("BytePackedRasters must have a bit depth of 1, 2, or 4");
}
scanlineStride = mppsm.getScanlineStride();
dataBitOffset = mppsm.getDataBitOffset() + dbOffset*8;
int xOffset = aRegion.x - origin.x;
int yOffset = aRegion.y - origin.y;
dataBitOffset += xOffset*pixelBitStride + yOffset*scanlineStride*8;
bitMask = (1 << pixelBitStride) -1;
shiftOffset = 8 - pixelBitStride;
} else {
throw new RasterFormatException("BytePackedRasters must have"+
"MultiPixelPackedSampleModel");
}
verify(false);
}
示例2: BytePackedRaster
import java.awt.image.DataBufferByte; //導入方法依賴的package包/類
/**
* Constructs a BytePackedRaster with the given SampleModel,
* DataBuffer, and parent. DataBuffer must be a DataBufferByte and
* SampleModel must be of type MultiPixelPackedSampleModel.
* 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.
*
* @exception RasterFormatException if the parameters do not conform
* to requirements of this Raster type.
*/
public BytePackedRaster(SampleModel sampleModel,
DataBufferByte dataBuffer,
Rectangle aRegion,
Point origin,
BytePackedRaster parent)
{
super(sampleModel,dataBuffer,aRegion,origin, parent);
this.maxX = minX + width;
this.maxY = minY + height;
this.data = stealData(dataBuffer, 0);
if (dataBuffer.getNumBanks() != 1) {
throw new
RasterFormatException("DataBuffer for BytePackedRasters"+
" must only have 1 bank.");
}
int dbOffset = dataBuffer.getOffset();
if (sampleModel instanceof MultiPixelPackedSampleModel) {
MultiPixelPackedSampleModel mppsm =
(MultiPixelPackedSampleModel)sampleModel;
this.type = IntegerComponentRaster.TYPE_BYTE_BINARY_SAMPLES;
pixelBitStride = mppsm.getPixelBitStride();
if (pixelBitStride != 1 &&
pixelBitStride != 2 &&
pixelBitStride != 4) {
throw new RasterFormatException
("BytePackedRasters must have a bit depth of 1, 2, or 4");
}
scanlineStride = mppsm.getScanlineStride();
dataBitOffset = mppsm.getDataBitOffset() + dbOffset*8;
int xOffset = aRegion.x - origin.x;
int yOffset = aRegion.y - origin.y;
dataBitOffset += xOffset*pixelBitStride + yOffset*scanlineStride*8;
bitMask = (1 << pixelBitStride) -1;
shiftOffset = 8 - pixelBitStride;
} else {
throw new RasterFormatException("BytePackedRasters must have"+
"MultiPixelPackedSampleModel");
}
verify(false);
}