Hi,
This is my first post here!
I want to use Images with palettes (IndexColorModel), but looking into the API, I cannot find the way to change the ColorModel to an Image.
I need this to make a sprite with cicling colors (like Megaman 5’s buster charge or Mariobros. star powerup)
The method I’m using is creating a new image with the new palette and then copiying the Raster form the first image.
Here is the code:
img = new BufferedImage(20, 30, BufferedImage.TYPE_BYTE_INDEXED, cm1);
WritableRaster rast = cm1.createCompatibleWritableRaster(20, 30);
rast.setPixels(0,0,20,30,spriteData);
img.setData(rast);
g.drawImage(img,0,0,this);
img2 = new BufferedImage(20, 30, BufferedImage.TYPE_BYTE_INDEXED, cm2);
img2.setData(rast);
g.drawImage(img2,40,40,this);
cm1 and cm2 are IndexColorModel Objects and spriteData is an array of index for the pixels in the image.
Anyone knows how to do this without creting an Image everytime I need to change the color palette??