Changing the palette of an image using IndexColorModel

Hi

How can I rapidly and often change the palette of a BufferedImage which uses an IndexColorModel? The only palette changes I want to implement are the colors, not the number of bits, palette size, transparencies or the transparent index.

The IndexColorModel class contains a private field rgb[] which I obviously cannot get a reference of, and two private methods IndexColorModel.setRGBs which only seem to be invoked from within the constructors.

Creating new IndexColorModel instances on the fly when I draw the same images (small icons) lots of times with different palettes (either as animation or as duplicates) creates unnecessary initialization overhead and garbage.

Is there another way to get the same effect?

[751 byte] By [Zom-Ba] at [2007-11-27 7:03:34]
# 1

Does nobody know?

Here is an example of what I'd like to do: http://tinyurl.com/28olro

I want to occasionally change the colors from reds to blue, green, gold or others and I want them to smoothly change.

I just want to know if it's even possible to do elegantly using the current API. I'm thinking of making a full-color MemoryImageSource and using an index->rgb array to translate colors on the fly.

Here's the source code if you want to see what I have: http://tinyurl.com/ywxn5d

Zom-Ba at 2007-7-12 18:54:49 > top of Java-index,Desktop,Core GUI APIs...