Last active
August 29, 2015 14:27
-
-
Save joernroeder/ef746c5c6d174eedde34 to your computer and use it in GitHub Desktop.
ScreenCapture processing example based on the solution from https://github.com/onformative/ScreenCapturer/issues/2#issuecomment-59645559
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.Robot; | |
import java.awt.Rectangle; | |
import java.awt.AWTException; | |
class SimpleScreenCapture { | |
Robot robot; | |
PImage screenshot; | |
SimpleScreenCapture() { | |
try { | |
robot = new Robot(); | |
} | |
catch (AWTException e) { | |
println(e); | |
} | |
} | |
PImage get() { | |
return this.get(0, 0); | |
} | |
PImage get(int x, int y) { | |
return this.get(x, y, width, height); | |
} | |
PImage get(int x, int y, int w, int h) { | |
return new PImage(robot.createScreenCapture(new Rectangle(x, y, w, h))); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SimpleScreenCapture simpleScreenCapture; | |
void setup() { | |
size(600, 400); | |
simpleScreenCapture = new SimpleScreenCapture(); | |
} | |
void draw() { | |
image(simpleScreenCapture.get(), 0, 0, width, height); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment