{
Object firstKey = params.keySet().iterator().next();
throw new ImageWriteException("Unknown parameter: " + firstKey);
}
PaletteFactory paletteFactory = new PaletteFactory();
boolean hasTransparency = false;
if (paletteFactory.hasTransparency(src, 1))
hasTransparency = true;
SimplePalette palette = null;
int maxColors = writePalette.length;
int charsPerPixel = 1;
for (; palette == null; )
{
palette = paletteFactory.makePaletteSimple(src,
hasTransparency ? maxColors - 1 : maxColors);
if (palette == null)
{
maxColors *= writePalette.length;
charsPerPixel++;