}
PlanarImage alphaChannel=null;
if (hasAlpha || doInputTransparency) {
ImageWorker w = new ImageWorker(granule);
if (granule.getSampleModel() instanceof MultiPixelPackedSampleModel||granule.getColorModel() instanceof IndexColorModel) {
w.forceComponentColorModel();
granule=w.getRenderedImage();
}
// doing this here gives the guarantee that I get the correct index for the transparency band
alphaIndex[0] = granule.getColorModel().getNumComponents() - 1;
assert alphaIndex[0]< granule.getSampleModel().getNumBands();