Robot.createScreenCapture() does not work with unity-2d

Bug #999170 reported by Michael Stringer
34
This bug affects 5 people
Affects Status Importance Assigned to Milestone
OpenJDK
New
Undecided
Unassigned
openjdk-6 (Ubuntu)
Confirmed
Undecided
Unassigned
openjdk-7 (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

The built in Java screen grabber (java.awt.Robot.createScreenCapture(...)) does not work correctly with unity-2d. When attempting to create a screen capture for the whole screen only the dash and menu bars are captured - everything else is black. This only affects unity-2d not unity or KDE.

Simple test case:

import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;

public class ScreenGrab {
  public static void main(String[] args) {
    try {
      Rectangle grabRect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
      Robot robot = new Robot();
      BufferedImage capture = robot.createScreenCapture(grabRect);
      ImageIO.write(capture, "PNG", new File("java-screen-shot.png"));
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}

ProblemType: Bug
DistroRelease: Ubuntu 12.04
Package: openjdk-6-jre 6b24-1.11.1-4ubuntu2
ProcVersionSignature: Ubuntu 3.2.0-24.37-generic 3.2.14
Uname: Linux 3.2.0-24-generic i686
ApportVersion: 2.0.1-0ubuntu7
Architecture: i386
Date: Mon May 14 15:51:34 2012
InstallationMedia: Ubuntu 11.04 "Natty Narwhal" - Release i386 (20110427.1)
ProcEnviron:
 LANGUAGE=en_GB:en
 TERM=xterm
 PATH=(custom, user)
 LANG=en_GB.UTF-8
 SHELL=/bin/bash
SourcePackage: openjdk-6
UpgradeStatus: Upgraded to precise on 2012-04-23 (20 days ago)

Revision history for this message
Michael Stringer (stringbean) wrote :
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in openjdk-6 (Ubuntu):
status: New → Confirmed
Changed in openjdk-7 (Ubuntu):
status: New → Confirmed
Revision history for this message
Annu (anu-katta10) wrote :

Please give the solution to capture the image properly with out any black screen. Is there any solution to capture the screen in java apart from java.awt.Robot class.

Revision history for this message
Naviathan (naviathan) wrote :

This was reported in May of 2012, almost 2 year ago...Why is not even assigned? It's still an issue!

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.