本文整理汇总了Java中sun.awt.image.ByteBandedRaster类的典型用法代码示例。如果您正苦于以下问题:Java ByteBandedRaster类的具体用法?Java ByteBandedRaster怎么用?Java ByteBandedRaster使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ByteBandedRaster类属于sun.awt.image包,在下文中一共展示了ByteBandedRaster类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createBandedRaster
import sun.awt.image.ByteBandedRaster; //导入依赖的package包/类
/**
* Creates a Raster based on a BandedSampleModel with the
* specified DataBuffer, width, height, scanline stride, bank
* indices, and band offsets. The number of bands is inferred
* from bankIndices.length and bandOffsets.length, which must be
* the same. The upper left corner of the Raster is given by the
* location argument. If location is null, (0, 0) will be used.
* @param dataBuffer the <code>DataBuffer</code> that contains the
* image data
* @param w the width in pixels of the image data
* @param h the height in pixels of the image data
* @param scanlineStride the line stride of the image data
* @param bankIndices the bank indices for each band
* @param bandOffsets the offsets of all bands
* @param location the upper-left corner of the <code>Raster</code>
* @return a WritableRaster object with the specified
* <code>DataBuffer</code>, width, height, scanline stride,
* bank indices and band offsets.
* @throws RasterFormatException if <code>w</code> or <code>h</code>
* is less than or equal to zero, or computing either
* <code>location.x + w</code> or
* <code>location.y + h</code> results in integer
* overflow
* @throws IllegalArgumentException if <code>dataType</code> is not
* one of the supported data types, which are
* <code>DataBuffer.TYPE_BYTE</code>,
* <code>DataBuffer.TYPE_USHORT</code>
* or <code>DataBuffer.TYPE_INT</code>
* @throws NullPointerException if <code>dataBuffer</code> is null
*/
public static WritableRaster createBandedRaster(DataBuffer dataBuffer,
int w, int h,
int scanlineStride,
int bankIndices[],
int bandOffsets[],
Point location) {
if (dataBuffer == null) {
throw new NullPointerException("DataBuffer cannot be null");
}
if (location == null) {
location = new Point(0,0);
}
int dataType = dataBuffer.getDataType();
int bands = bankIndices.length;
if (bandOffsets.length != bands) {
throw new IllegalArgumentException(
"bankIndices.length != bandOffsets.length");
}
BandedSampleModel bsm =
new BandedSampleModel(dataType, w, h,
scanlineStride,
bankIndices, bandOffsets);
switch(dataType) {
case DataBuffer.TYPE_BYTE:
return new ByteBandedRaster(bsm, dataBuffer, location);
case DataBuffer.TYPE_USHORT:
return new ShortBandedRaster(bsm, dataBuffer, location);
case DataBuffer.TYPE_INT:
return new SunWritableRaster(bsm, dataBuffer, location);
default:
throw new IllegalArgumentException("Unsupported data type " +
dataType);
}
}
示例2: createBandedRaster
import sun.awt.image.ByteBandedRaster; //导入依赖的package包/类
/**
* Creates a Raster based on a BandedSampleModel with the
* specified DataBuffer, width, height, scanline stride, bank
* indices, and band offsets. The number of bands is inferred
* from bankIndices.length and bandOffsets.length, which must be
* the same. The upper left corner of the Raster is given by the
* location argument. If location is null, (0, 0) will be used.
* @param dataBuffer the <code>DataBuffer</code> that contains the
* image data
* @param w the width in pixels of the image data
* @param h the height in pixels of the image data
* @param scanlineStride the line stride of the image data
* @param bankIndices the bank indices for each band
* @param bandOffsets the offsets of all bands
* @param location the upper-left corner of the <code>Raster</code>
* @return a WritableRaster object with the specified
* <code>DataBuffer</code>, width, height, scanline stride,
* bank indices and band offsets.
* @throws RasterFormatException if <code>w</code> or <code>h</code>
* is less than or equal to zero, or computing either
* <code>location.x + w</code> or
* <code>location.y + h</code> results in integer
* overflow
* @throws IllegalArgumentException if <code>dataType</code> is not
* one of the supported data types, which are
* <code>DataBuffer.TYPE_BYTE</code>,
* <code>DataBuffer.TYPE_USHORT</code>
* or <code>DataBuffer.TYPE_INT</code>
* @throws NullPointerException if <code>dataBuffer</code> is null
*/
public static WritableRaster createBandedRaster(DataBuffer dataBuffer,
int w, int h,
int scanlineStride,
int bankIndices[],
int bandOffsets[],
Point location) {
if (dataBuffer == null) {
throw new NullPointerException("DataBuffer cannot be null");
}
if (location == null) {
location = new Point(0,0);
}
int dataType = dataBuffer.getDataType();
int bands = bankIndices.length;
if (bandOffsets.length != bands) {
throw new IllegalArgumentException(
"bankIndices.length != bandOffsets.length");
}
BandedSampleModel bsm =
new BandedSampleModel(dataType, w, h,
scanlineStride,
bankIndices, bandOffsets);
switch(dataType) {
case DataBuffer.TYPE_BYTE:
return new ByteBandedRaster(bsm, dataBuffer, location);
case DataBuffer.TYPE_USHORT:
return new ShortBandedRaster(bsm, dataBuffer, location);
case DataBuffer.TYPE_INT:
return new SunWritableRaster(bsm, dataBuffer, location);
default:
throw new IllegalArgumentException("Unsupported data type " +
dataType);
}
}