Setup screen capture robot
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
e99eaa0f43
commit
84a3ce417c
Binary file not shown.
@ -1,9 +1,19 @@
|
||||
package sig;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.AWTException;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.JFrame;
|
||||
|
||||
import java.awt.Robot;
|
||||
import sig.engine.Panel;
|
||||
|
||||
public class ArcadeScreenshotHandler {
|
||||
public static Robot r;
|
||||
public static final String PROGRAM_NAME="Sig's Java Project Template";
|
||||
public static void main(String[] args) {
|
||||
JFrame f = new JFrame(PROGRAM_NAME);
|
||||
@ -17,5 +27,19 @@ public class ArcadeScreenshotHandler {
|
||||
f.setVisible(true);
|
||||
|
||||
p.render();
|
||||
|
||||
try {
|
||||
r = new Robot();
|
||||
BufferedImage img = CaptureScreen();
|
||||
ImageIO.write(img,"png",Path.of("screenshot.png").toFile());
|
||||
} catch (AWTException | IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static BufferedImage CaptureScreen() throws IOException {
|
||||
BufferedImage screenshot = r.createScreenCapture(GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds());
|
||||
//ImageIO.write(screenshot,"png",new File("screenshot.png"));
|
||||
return screenshot;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user