public class ScreenshotTaker extends Object
Modifier and Type | Field and Description |
---|---|
static String |
PNG_EXTENSION
Deprecated.
use
instead. |
Constructor and Description |
---|
ScreenshotTaker()
Creates a new
. |
Modifier and Type | Method and Description |
---|---|
void |
saveComponentAsPng(Component c,
String imageFilePath)
Takes a screenshot of the given
and saves it as a PNG file. |
void |
saveDesktopAsPng(String imageFilePath)
Takes a screenshot of the desktop and saves it as a PNG file.
|
void |
saveImage(BufferedImage image,
String filePath)
Save the given image as a PNG file.
|
BufferedImage |
takeDesktopScreenshot()
Takes a screenshot of the desktop.
|
BufferedImage |
takeScreenshotOf(Component c)
Takes a screenshot of the given
. |
@Deprecated public static final String PNG_EXTENSION
ImageFileExtensions.PNG
instead.public ScreenshotTaker()
ScreenshotTaker
.ImageException
- if a AWT Robot (the responsible for taking screenshots) cannot be instantiated.public void saveDesktopAsPng(String imageFilePath)
imageFilePath
- the path of the file to save the screenshot to.ImageException
- if the given file path is null
or empty.ImageException
- if the given file path does not end with ".png".ImageException
- if the given file path belongs to a non-empty directory.ImageException
- if an I/O error prevents the image from being saved as a file.public BufferedImage takeDesktopScreenshot()
SecurityException
- if readDisplayPixels
permission is not granted.public void saveComponentAsPng(Component c, String imageFilePath)
Component
and saves it as a PNG file.c
- the given component.imageFilePath
- the path of the file to save the screenshot to.ImageException
- if the given file path is null
or empty.ImageException
- if the given file path does not end with ".png".ImageException
- if the given file path belongs to a non-empty directory.ImageException
- if an I/O error prevents the image from being saved as a file.public BufferedImage takeScreenshotOf(Component c)
Component
.c
- the given component.SecurityException
- if readDisplayPixels
permission is not granted.public void saveImage(BufferedImage image, String filePath)
image
- the image to save.filePath
- the path of the file to save the image to.ImageException
- if the given file path is null
or empty.ImageException
- if the given file path does not end with ".png".ImageException
- if the given file path belongs to a non-empty directory.ImageException
- if an I/O error prevents the image from being saved as a file.Copyright © 2007-2012 FEST (Fixtures for Easy Software Testing). All Rights Reserved.