Java实现屏幕截图获取需要使用java.awt包下的工具类
一个最简单的获取屏幕截图的代码实现如下所示:
import java.awt.AWTException;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
public class ScreenshotGetter {
public BufferedImage getScreenshot() throws AWTException {
final Robot robot = new Robot();
Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
int width = (int) dimension.getWidth();
int height = (int) dimension.getHeight();
BufferedImage screenshot = robot.createScreenCapture(new Rectangle(0,
0, width, height));
return screenshot;
}
}
本文链接:http://bookshadow.com/weblog/2014/05/16/java-screenshot-demo/
请尊重作者的劳动成果,转载请注明出处!书影博客保留对文章的所有权利。