this.maxY = minY + height;
if (!(dataBuffer instanceof DataBufferInt)) {
throw new RasterFormatException("IntegerComponentRasters must have" +
"integer DataBuffers");
}
DataBufferInt dbi = (DataBufferInt)dataBuffer;
if (dbi.getNumBanks() != 1) {
throw new
RasterFormatException("DataBuffer for IntegerComponentRasters"+
" must only have 1 bank.");
}
this.data = stealData(dbi, 0);
if (sampleModel instanceof SinglePixelPackedSampleModel) {
SinglePixelPackedSampleModel sppsm =
(SinglePixelPackedSampleModel)sampleModel;
int[] boffsets = sppsm.getBitOffsets();
boolean notByteBoundary = false;
for (int i=1; i < boffsets.length; i++) {
if ((boffsets[i]%8) != 0) {
notByteBoundary = true;
}
}
this.type = (notByteBoundary
? IntegerComponentRaster.TYPE_INT_PACKED_SAMPLES
: IntegerComponentRaster.TYPE_INT_8BIT_SAMPLES);
this.scanlineStride = sppsm.getScanlineStride();
this.pixelStride = 1;
this.dataOffsets = new int[1];
this.dataOffsets[0] = dbi.getOffset();
this.bandOffset = this.dataOffsets[0];
int xOffset = aRegion.x - origin.x;
int yOffset = aRegion.y - origin.y;
dataOffsets[0] += xOffset+yOffset*scanlineStride;
this.numDataElems = sppsm.getNumDataElements();