ComponentSampleModel sm = (ComponentSampleModel)raster.getSampleModel();
if (type == sampleType) {
// Data are stored in the requested array type; no need to copy.
DataBuffer db = raster.getDataBuffer();
int[] bankIndices = sm.getBankIndices();
switch (sampleType) {
case DataBuffer.TYPE_BYTE:
byte[][] bbd = ((DataBufferByte)db).getBankData();
byte[][] bd = new byte[numBands][];
for (int b = 0; b < numBands; b++) {
bd[b] = bbd[bankIndices[b]];
}
data = bd;
break;
case DataBuffer.TYPE_USHORT:
case DataBuffer.TYPE_SHORT:
short[][] sbd = sampleType == DataBuffer.TYPE_USHORT ?
((DataBufferUShort)db).getBankData() :
((DataBufferShort)db).getBankData();
short[][] sd = new short[numBands][];
for (int b = 0; b < numBands; b++) {
sd[b] = sbd[bankIndices[b]];
}
data = sd;
break;
case DataBuffer.TYPE_INT:
int[][] ibd = ((DataBufferInt)db).getBankData();
int[][] id = new int[numBands][];
for (int b = 0; b < numBands; b++) {
id[b] = ibd[bankIndices[b]];
}
data = id;
break;
case DataBuffer.TYPE_FLOAT:
float[][] fbd = DataBufferUtils.getBankDataFloat(db);
float[][] fd = new float[numBands][];
for (int b = 0; b < numBands; b++) {
fd[b] = fbd[bankIndices[b]];
}
data = fd;
break;
case DataBuffer.TYPE_DOUBLE:
double[][] dbd = DataBufferUtils.getBankDataDouble(db);
double[][] dd = new double[numBands][];
for (int b = 0; b < numBands; b++) {
dd[b] = dbd[bankIndices[b]];
}
data = dd;
break;
}
pixelStride = sm.getPixelStride();
lineStride = sm.getScanlineStride();
// Determine offsets.
int[] dbOffsets = db.getOffsets(); // DataBuffer offsets
int x = rect.x - raster.getSampleModelTranslateX();
int y = rect.y - raster.getSampleModelTranslateY();
offsets = new int[numBands];
for (int b = 0; b < numBands; b++) {