use of sun.awt.image.ByteBandedRaster in project jdk8u_jdk by JetBrains.
the class Raster method createBandedRaster.
/**
* 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);
}
}
Aggregations