Bug 367 - File created by Screenshot might be flipped vertically
Summary: File created by Screenshot might be flipped vertically
Status: RESOLVED WONTFIX
Alias: None
Product: Jogl
Classification: JogAmp
Component: awt (show other bugs)
Version: 1
Hardware: All windows
: P4 normal
Assignee: Sven Gothel
URL:
Depends on:
Blocks:
 
Reported: 2009-01-28 05:58 CET by Sven Gothel
Modified: 2012-09-30 21:11 CEST (History)
0 users

See Also:
Type: DEFECT
SCM Refs:
Workaround: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.