Bug 367

Summary: File created by Screenshot might be flipped vertically
Product: [JogAmp] Jogl Reporter: Sven Gothel <sgothel>
Component: awtAssignee: Sven Gothel <sgothel>
Status: RESOLVED WONTFIX    
Severity: normal    
Priority: P4    
Version: 1   
Hardware: All   
OS: windows   
Type: DEFECT SCM Refs:
Workaround: ---

Description Sven Gothel 2010-03-24 07:51:42 CET


---- Reported by gibe 2009-01-28 05:58:21 ----

When taking a screen shot using the Screenshot class, the exported image might
be flipped vertically.
Actually, it happens on Windows with GLJPanel and when pbuffers are disabled.

The problem comes from the vertical flip of the image by the Screenshot class.
Unlike the display method of the GLJPanel, the Screenshot class always performs
the flip. In the GLJPanel, before displaying the image, a check is done to know
whether the image should be flipped or not. This check obviously lacks in the
Screenshot class.



---- Additional Comments From gibe 2009-01-28 06:04:55 ----

Here is a workaround for the bug:
------------------------
// 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);
}
----------------

If you were using Screenshot.writeToFile, use the code above and
ImageIO.write(...) instead.




--- Bug imported by sgothel@jausoft.com 2010-03-24 07:51 EDT  ---

This bug was previously known as _bug_ 367 at https://jogl.dev.java.net/bugs/show_bug.cgi?id=367
Comment 1 Sven Gothel 2012-09-30 21:11:24 CEST
Root cause is the Windows software renderer, won't fix.