Java Utililty Methods Screen Capture

List of utility methods to do Screen Capture

  1. HOME
  2. Java
  3. S
  4. Screen Capture

Description

The list of methods to do Screen Capture are organized into topic(s).

Method

BufferedImage captureScreen()
capture Screen
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Rectangle screenRectangle = new Rectangle(screenSize);
Robot robot = new Robot();
BufferedImage image = robot.createScreenCapture(screenRectangle);
return image;
BufferedImage captureScreen(final Rectangle screenRect)
capture Screen
if (robot == null) {
 throw new AWTException("the platform configuration does not allow low-level input control");
return robot.createScreenCapture(screenRect);
BufferedImage captureScreen(Rectangle rect)
capture Screen
try {
 return (new Robot()).createScreenCapture(rect);
} catch (AWTException e) {
return null;
void captureScreen(String filename)
Captures the screen.
BufferedImage image = new Robot()
 .createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
ImageIO.write(image, "png", new File(filename));
BufferedImage screenshot(Rectangle dims, Robot r)
screenshot
BufferedImage screenshot = r.createScreenCapture(dims);
return screenshot;
byte[] screenShot(String format)
Stores a screenshot to the bynary array.
try {
 Robot robot = new Robot();
 Rectangle captureSize = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
 BufferedImage bufferedImage = robot.createScreenCapture(captureSize);
 ByteArrayOutputStream bo = new ByteArrayOutputStream();
 ImageIO.write(bufferedImage, format, bo);
 return bo.toByteArray();
} catch (AWTException e) {
...
byte[] takeScreenShot(boolean showCursor)
This function handle the sreenshot
ByteArrayOutputStream baos = new ByteArrayOutputStream();
BufferedImage img = null;
byte[] out = null;
try {
 img = new Robot().createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
 if (showCursor) {
 Image cursor = ImageIO.read(new File("res/ratty/img/cursor.gif"));
 int x = MouseInfo.getPointerInfo().getLocation().x;
...
void takeScreenshot(String fileName, String formatName)
take Screenshot
Rectangle screenBounds = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
BufferedImage image = new Robot().createScreenCapture(screenBounds);
ImageIO.write(image, formatName, new File(fileName));


AltStyle によって変換されたページ (->オリジナル) /