private static Map configHelper(Map configuration) {
Map config;
if (configuration == null) {
config = new RenderingHints(JAI.KEY_REPLACE_INDEX_COLOR_MODEL,
Boolean.TRUE);
} else {
config = configuration;
// If the user specified a value for this hint, we don't
// want to change that
if (!config.containsKey(JAI.KEY_REPLACE_INDEX_COLOR_MODEL)) {
RenderingHints hints = new RenderingHints(null);
// This is effectively a clone of configuration
hints.putAll(configuration);
config = hints;
config.put(JAI.KEY_REPLACE_INDEX_COLOR_MODEL, Boolean.TRUE);
}
}