Today, I ran into weird issue: java.awt.Robot
captures black areas, instead of image content. I'm using Ubuntu 12.04 and OpenJDK6/7.
java.awt.Robot
on Unix is supported by the sun.awt.X11.XRobotPeer
,
which, following the corresponding OpenJDK sources, uses image grabbing functions similar to those, used by xwd
utililty (lines 92-162).
So, I ran the following command:
xwd -root -out test.screen.root.xwd
and then opened this file with gimp. Here's what I get:
Then I tried:
xwd -root | xwdtopnm | pnmtopng > Screenshot.root.png
And I got the following result: Console output:
xwdtopnm: writing PPM file
libpng warning: Invalid sBIT depth specified
And the image itself:
What can cause this? How can I fix it?
Seems like the only way to fix this is to use your own native implementation of screen shotting.
Here's the detailed description of the problem at the launchpad from unity devs: launchpad conversation.
The problem is in the way unity-2d draws itself and in the use of XShaping.