Pegando capturando a tela em Java
Posted: 08 Feb 2023, 06:43
Code: Select all
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;
public class ScreenRecorder {
private static final int FRAME_RATE = 30;
public static void main(String[] args) {
try {
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Rectangle screenRectangle = new Rectangle(screenSize);
Robot robot = new Robot();
BufferedImage minhaTela = robot.createScreenCapture(screenRectangle);
ImageIO.write(minhaTela, "png", new File("/tmp/screen.png"));
}
catch (Exception e) {
System.out.println("Errrou amiguinho:"+e);
}
}
}