super(sampleModel, dataBuffer, aRegion, origin, parent);
this.maxX = minX + width;
this.maxY = minY + height;
if (!(dataBuffer instanceof DataBufferByte)) {
throw new RasterFormatException("ByteComponentRasters must have " +
"byte DataBuffers");
}
DataBufferByte dbb = (DataBufferByte)dataBuffer;
this.data = stealData(dbb, 0);
if (dbb.getNumBanks() != 1) {
throw new
RasterFormatException("DataBuffer for ByteComponentRasters"+
" must only have 1 bank.");
}
int dbOffset = dbb.getOffset();
if (sampleModel instanceof ComponentSampleModel) {
ComponentSampleModel ism = (ComponentSampleModel)sampleModel;
this.type = IntegerComponentRaster.TYPE_BYTE_SAMPLES;
this.scanlineStride = ism.getScanlineStride();
this.pixelStride = ism.getPixelStride();
this.dataOffsets = ism.getBandOffsets();
int xOffset = aRegion.x - origin.x;
int yOffset = aRegion.y - origin.y;
for (int i = 0; i < getNumDataElements(); i++) {
dataOffsets[i] += dbOffset +
xOffset*pixelStride+yOffset*scanlineStride;
}
} else if (sampleModel instanceof SinglePixelPackedSampleModel) {
SinglePixelPackedSampleModel sppsm =
(SinglePixelPackedSampleModel)sampleModel;
this.type = IntegerComponentRaster.TYPE_BYTE_PACKED_SAMPLES;
this.scanlineStride = sppsm.getScanlineStride();
this.pixelStride = 1;
this.dataOffsets = new int[1];
this.dataOffsets[0] = dbOffset;
int xOffset = aRegion.x - origin.x;
int yOffset = aRegion.y - origin.y;
dataOffsets[0] += xOffset*pixelStride+yOffset*scanlineStride;
} else {
throw new RasterFormatException("IntegerComponentRasters must " +
"have ComponentSampleModel or SinglePixelPackedSampleModel");
}
this.bandOffset = this.dataOffsets[0];
verify(false);