Hello,
I have a gif image that i load with ImageIO. It has 3 colors + transparent background(saved with gimp, indexed mode, 3 colors). I want to be able to use several different paletes for this image, infact i want to create another bufferedimage, with new palete and draw the old one on it.
int[] cmap = { 0xff2e00a4, 0xff2401d6, 0xff6c4eee, 0x00000000};
IndexColorModel icm = new IndexColorModel(8, cmap.length, cmap, 0,true,3,DataBuffer.TYPE_BYTE);
BufferedImage image = new BufferedImage(20,25,BufferedImage.TYPE_BYTE_INDEXED,icm);
Graphics2D g2d = (Graphics2D)image.getGraphics();
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR, 0.0f));
g2d.fillRect(0, 0, 20, 25);
The problem is that when i draw the original image on it, only one color is visible, ant the two others seem to be transparent.
The code:
IndexColorModel cm = (IndexColorModel)originalImage.getColorModel();
System.out.println(cm.getMapSize());
System.out.println(cm.getTransparentPixel());
Prints 4,3.
Any ideas?