ColorModel cm;
if (pmi.isMonochrome()) {
int[] overlayGroupOffsets = getActiveOverlayGroupOffsets(param);
byte[][] overlayData = new byte[overlayGroupOffsets.length][];
for (int i = 0; i < overlayGroupOffsets.length; i++) {
overlayData[i] = extractOverlay(overlayGroupOffsets[i], raster);
}
cm = createColorModel(8, DataBuffer.TYPE_BYTE);
SampleModel sm = createSampleModel(DataBuffer.TYPE_BYTE, false);
raster = applyLUTs(raster, frameIndex, param, sm, 8);
for (int i = 0; i < overlayGroupOffsets.length; i++) {
applyOverlay(overlayGroupOffsets[i],
raster, frameIndex, param, 8, overlayData[i]);
}
} else {
cm = createColorModel(bitsStored, dataType);
}
return new BufferedImage(cm, raster , false, null);