super(sampleModel, dataBuffer, aRegion, origin, parent);
this.maxX = minX + width;
this.maxY = minY + height;
if(!(dataBuffer instanceof DataBufferUShort)) {
throw new RasterFormatException("ShortComponentRasters must have "+
"short DataBuffers");
}
DataBufferUShort dbus = (DataBufferUShort)dataBuffer;
this.data = stealData(dbus, 0);
if (dbus.getNumBanks() != 1) {
throw new
RasterFormatException("DataBuffer for ShortComponentRasters"+
" must only have 1 bank.");
}
int dbOffset = dbus.getOffset();
if (sampleModel instanceof ComponentSampleModel) {
ComponentSampleModel csm = (ComponentSampleModel)sampleModel;
this.type = IntegerComponentRaster.TYPE_USHORT_SAMPLES;
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] += dbOffset +
xOffset*pixelStride+yOffset*scanlineStride;
}
} else if (sampleModel instanceof SinglePixelPackedSampleModel) {
SinglePixelPackedSampleModel sppsm =
(SinglePixelPackedSampleModel)sampleModel;
this.type = IntegerComponentRaster.TYPE_USHORT_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+yOffset*scanlineStride;
} else {
throw new RasterFormatException("ShortComponentRasters must have"+
"ComponentSampleModel or SinglePixelPackedSampleModel");
}
this.bandOffset = this.dataOffsets[0];
verify(false);