Do I need new images for that, or can I say “Turn all the
blue pixels white”? And will it be hardware-accelerated?
I usually do it the other way 'round. They are white and I ignore the colors (chanels) I don’t need.
private void createPlayerImages()
{
int h=wPlayer.getHeight(null);
int w=wPlayer.getWidth(null);
int gpixels[] = new int[h * w];
PixelGrabber pixelgrabber = new PixelGrabber(wPlayer, 0, 0, w, h, gpixels, 0, w);
try
{
pixelgrabber.grabPixels();
}
catch(InterruptedException interruptedexception)
{
GUI.dm.printErr("interrupted waiting for pixels!");
}
if((pixelgrabber.getStatus() & ImageObserver.ERROR) != 0)
GUI.dm.printErr("image fetch aborted or errored");
int pixels[] = new int[h * w * 4];
Image img = createImage(new MemoryImageSource(w * 4, h, ColorModel.getRGBdefault(), pixels, 0, w * 4));
/*
Number of bits: 32
Red mask: 0x00ff0000
Green mask: 0x0000ff00
Blue mask: 0x000000ff
Alpha mask: 0xff000000
Color space: sRGB
isAlphaPremultiplied: False
Transparency: Transparency.TRANSLUCENT
transferType: DataBuffer.TYPE_INT
*/
for(int y=0;y<h;y++)
{
for(int x=0;x<w;x++)
{
int pixel = gpixels[x+y*w];
int alpha = pixel & 0xff000000;
int red = pixel & 0x00ff0000;
int green = pixel & 0x0000ff00;
int blue = pixel & 0x000000ff;
pixels[x+w*0 + y*w*4]=alpha | red; //red player
pixels[x+w*1 + y*w*4]=alpha | green; //green player
pixels[x+w*2 + y*w*4]=alpha | blue; //blue player
pixels[x+w*3 + y*w*4]=alpha | red | green; //yellow player
}
}
if(img != null)
img.flush();
players = new BufferedImage[4];
for(int i=0;i<4;i++)
{
players[i]= gc.createCompatibleImage(w,h,Transparency.TRANSLUCENT);
Graphics2D tg = (Graphics2D)players[i].getGraphics();
tg.setComposite(AlphaComposite.Src);
tg.drawImage(img,
0,0,
w,h,
i*w,0,
i*w+w,h,
null);
tg.dispose();
}
}
After that method it’s like I just loaded 4 different sprites in different colors 
I grab the pixels of the white sprite, create a MemoryImageSource-Image wich is 4 times bigger, then I take each pixel apart into it’s channels (rgba), put em were they should be (red here the blue one there etc) and at the end I flush the image and copy each sprite into a BufferedImage.
Check this image: http://people.freenet.de/ki_onyx/ludo_mockup8.png
(The white sprite is the original all other sprites are generated by that method above. The whole thing is <8kb :))
If you need rotation you can use AffineTransform either to rotate in realtime or to create the amount of rotated images, you’ll need, at the beginning. However, creating em at the beginning is usually the way to go, because it’s faster and doesn’t create that much garbage.