Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dual Monitor Screenshots - One Blank



Rob Eden wrote:

I'm trying to take screen shots using java.awt.Robot, but not having
the best of luck on dual monitors setups. When I do so, the image
from the second screen is all black.

I'm assuming this is a bug, but before I filed one, I figured I'd let
you guys take a look to make sure I'm not doing anything silly.

I have found Apple's implementation of Robot.createScreenCapture to have some idiosyncrasies. In some versions of Apple's JVM, you can cause the JVM (in particular early 1.4.1 releases) to crash by passing incorrect bounding rectangles. I found I got reliable results by instantiating a per-display Robot to capture each display.


I also found that the bounding rectangle given to createScreenCapture needed to be in device-coords, not in global (desktop) coords, for all platforms *except* OS X 10.2 (all JVMs) and 10.3+ (1.4+ JVMs) -- which require global coords. For a full-display capture you should just be able to set the X and Y values of the bounding rectangle to zero. I haven't revisited this issue since Panther, so the situation may have changed, although my existing code (implementing the logic I outlined) still seems to work in J2SE5. I also found that some platform/JVM combinations would accept *either* co-ordinate system. Windows JVMs also had some idiosyncrasies, but I've forgotten the details. I tested with 1.3.1, 1.4.1 and 1.4.2 on OS X 10.1 through 10.3, Win 95, 98, ME, 2K, XP, Solaris 9 and 10, and a few different Linux distros. Getting this to work cross-platform was a major PITA.

Example:
    Robot robbie = new Robot(devices[i]);
    Rectangle bounds = new Rectangle (config.getBounds());
    if ( !OSX_10_2 && ! (OSX_10_3_PLUS && JAVA_14_PLUS))
        bounds.x = bounds.y = 0;
    images[i] = robbie.createScreenCapture (bounds);
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.