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);
}