ret.stride = ((ComponentSampleModel) sm).getScanlineStride();
ret.channelsOrder = ((ComponentSampleModel) sm).getBandOffsets();
} else if (sm instanceof SinglePixelPackedSampleModel) {
// Check SinglePixelPackedSampleModel
SinglePixelPackedSampleModel sppsm1 = (SinglePixelPackedSampleModel) sm;
ret.channels = sppsm1.getNumBands();
if (sppsm1.getDataType() != DataBuffer.TYPE_INT) {
return null;
}
// Check sample models
for (int i=0; i<ret.channels; i++) {
if (sppsm1.getSampleSize(i) != 8) {
return null;
}
}
ret.channelsOrder = new int[ret.channels];
int bitOffsets[] = sppsm1.getBitOffsets();
for (int i=0; i<ret.channels; i++) {
if (bitOffsets[i] % 8 != 0) {
return null;
}
ret.channelsOrder[i] = bitOffsets[i] / 8;
}
ret.channels = 4;
ret.stride = sppsm1.getScanlineStride() * 4;
} else {
return null;
}
return ret;