if(!(dataBuffer instanceof DataBufferUShort)) {
throw new RasterFormatException("ShortInterleavedRasters must "+
"have ushort DataBuffers");
}
DataBufferUShort dbus = (DataBufferUShort)dataBuffer;
this.data = stealData(dbus, 0);
// REMIND: need case for interleaved ComponentSampleModel
if ((sampleModel instanceof PixelInterleavedSampleModel) ||
(sampleModel instanceof ComponentSampleModel &&
sampleModel.getNumBands() == 1)) {
ComponentSampleModel csm = (ComponentSampleModel)sampleModel;
this.scanlineStride = csm.getScanlineStride();
this.pixelStride = csm.getPixelStride();
this.dataOffsets = csm.getBandOffsets();
int xOffset = aRegion.x - origin.x;
int yOffset = aRegion.y - origin.y;
for (int i = 0; i < getNumDataElements(); i++) {
dataOffsets[i] += xOffset*pixelStride+yOffset*scanlineStride;
}
} else if (sampleModel instanceof SinglePixelPackedSampleModel) {
SinglePixelPackedSampleModel sppsm =
(SinglePixelPackedSampleModel)sampleModel;
this.scanlineStride = sppsm.getScanlineStride();
this.pixelStride = 1;
this.dataOffsets = new int[1];
this.dataOffsets[0] = dbus.getOffset();
int xOffset = aRegion.x - origin.x;
int yOffset = aRegion.y - origin.y;
dataOffsets[0] += xOffset+yOffset*scanlineStride;
} else {
throw new RasterFormatException("ShortInterleavedRasters must "+