if (fileName.endsWith("pal")) {
final IndexColorModel icm = new PALFileLoader(file)
.getIndexColorModel();
if (icm != null) {
final InverseColorMapOp eicm = new InverseColorMapOp(
icm);
paletteCache.put(name, new PaletteCacheEntry(file, eicm));
return eicm;
}
} else {
ImageInputStream iis = ImageIO.createImageInputStream(file);
final Iterator it = ImageIO.getImageReaders(iis);
if (it.hasNext()) {
final ImageReader reader = (ImageReader) it.next();
reader.setInput(iis);
final ColorModel cm = ((ImageTypeSpecifier) reader
.getImageTypes(0).next()).getColorModel();
if (cm instanceof IndexColorModel) {
final IndexColorModel icm = (IndexColorModel) cm;
final InverseColorMapOp eicm = new InverseColorMapOp(
icm);
paletteCache.put(name,
new PaletteCacheEntry(file, eicm));
return eicm;
}