Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- //Set the output boundaries
- static final int x1 = 0;
- static final int x2 = 1920;
- static final int y1 = 0;
- static final int y2 = 1080;
- //There's no need to keep creating new Rectangles
- Rectangle captureSpace;
- Image img;
- PImage pimg;
- Robot robot;
- void settings() {
- size(x2, y2, FX2D);
- noSmooth();
- }
- void setup() {
- frameRate(30);
- try {
- robot = new Robot();
- }
- catch (AWTException cause) {
- println(cause);
- exit();
- }
- //Set the input boundaries
- captureSpace = new Rectangle(0, 0, displayWidth, displayHeight-50);
- //inputDimensions = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
- }
- void draw() {
- //Set the window title to the current framerate.
- surface.setTitle("FPS: " + Math.round(frameRate));
- //You have more control over how the image is resized with getScaledInstance
- img = robot.createScreenCapture(captureSpace).getScaledInstance(x2, y2, Image.SCALE_FAST);
- pimg = new PImage(img);
- image(pimg, 0, 0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement