I recently discovered that the Screenshot class was producing vertically flipped images on some configurations.
It only happens under Windows, with the GLJPanel and when pbuffers are not supported (when using Windows through VMware for example or with some old intel GC).
If you are experiencing such a bug here is a workaround I found by looking at the GLJPanel source code. Actually, the GLJPanel is also making some kind of screenShot from its offscreen buffer and display it on a JPanel.
Instead of doing
BufferedImage img = Screenshot.readToBufferedImage(getWidth(), getHeight());
do
// might unecessary flip the image
BufferedImage img = Screenshot.readToBufferedImage(getWidth(), getHeight());
// check if it was the case
boolean needFlip;
try {
// raises an exception if hardware acceleration is on
needFlip = !((GLContextImpl)GLContext.getCurrent()).offscreenImageNeedsVerticalFlip();
} catch (GLException e) {
// hardware acceleration is on
needFlip = false;
}
if (needFlip) {
// flip it back
ImageUtil.flipImageVertically(img);
}
And if you were using Screenshot.writeToFile method, just add ImageIO.write(…) to export the above image.