If I run this code:
BufferedImage image = new Robot().createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
ImageIO.write(image, "png", new File("takenwithrobot.png"));
It yields the following PNG: http://davzy.com/screenshots/takenwithrobot.png
If I take a screenshot using the built in OS X screen capture utility I get the following: http://davzy.com/screenshots/takenwithOSXscreenshotutility.png
As you can see the colours in both are completely different. After several experiments I determined that the colours in the above screenshot taken with the built in OS X utility have the correct colours, and the screenshot taken with robot have the complete wrong colours.
I am writing a script which compares pixel by pixel of screenshots, and so if robot is producing screenshots with wrong colours, it will not work. Interestingly enough if I run the above on a Windows machine it works just fine and gets the correct colours. I was thinking maybe the colour depth of robot was the cause of all the wrong colours, but I don't know if that's the problem and I don't know how to change it.