try {
dst = JAI.create("lookup", src, lut);
} catch (Exception e) {
LOGGER.error("jai-operation-failure", "lookup");
throw new ImageConvertorException(e);
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Converted from indexed to RGB");
ImageLogger.log(dst);
}
} else
if (cm instanceof ComponentColorModel &&
cm.getNumColorComponents() == 1) {
//Transform image with one colour component into image with three
//components.
int[] bandIndices;
//If we have no alpha data we should extend only colour components.
if (cm.getNumColorComponents() == cm.getNumComponents()) {
bandIndices = new int[]{
0, //Put the colour data into R(first) component
0, //Put the colour data into G(second) component
0};//Put the colour data into B(third) component
} else {
//In other case we should keep alpha data.
bandIndices = new int[]{
0, //Put the colour data into R(first) component
0, //Put the colour data into G(second) component
0, //Put the colour data into B(third) component
1};//Put the alpha data into A(fourth) component
}
//Construct the ParameterBlock.
ParameterBlock parameters = new ParameterBlock();
parameters.addSource(src);
parameters.add(bandIndices);
try {
dst = JAI.create("bandSelect", parameters);
} catch (Exception e) {
LOGGER.error("jai-operation-failure", "bandSelect");
throw new ImageConvertorException(e);
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Number of colour components extended");
ImageLogger.log(dst);
}