Speicifically I have images that are all solid black on transparent. I want to assign an abritrary colour to the images when they are drawn so that the black areas are changed to the new colour.
I tried using a RGBImageFilter that just returned the colour I want but something's going wrong and nothing is being drawn at all. (ColourFilter extends RGBImageFilter and just returns the set colour in it's filterRGB() method.)
BufferedImage tileImage = _tiles.get( tileID );
ColourFilter cFilt = new ColourFilter();
cFilt.setColour( colour );
FilteredImageSource filteredSrc = new FilteredImageSource( tileImage.getSource(), cFilt );
Image finalImage = Toolkit.getDefaultToolkit().createImage(filteredSrc);
bufferGraphics2D.drawImage(finalImage.....
Look at AlphaComposites, particularly DST_IN:
I'm not 100% sure what you're trying to do, but image filters and should be able to do what I think you are trying to do. For e.g.,