Advertisement
xeromino

gaga

Feb 22nd, 2016
232
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // part of this code comes from here: https://forum.processing.org/two/discussion/4612/how-do-i-take-several-screenshots-from-the-same-part-of-the-display-and-work-with-these
  2.  
  3. import java.awt.Robot;
  4. import java.awt.Rectangle;
  5. import java.awt.AWTException;
  6.  
  7. PImage screenshot;
  8. boolean smoothOn;
  9. int x, y, step = 10;
  10. int w = 855, h = 480, w2 = int(w*.9), h2 =int(h*.9);
  11. boolean save = false;
  12.  
  13. void settings() {
  14. size(w2, h2);
  15. }
  16.  
  17. void setup() {
  18. }
  19.  
  20. void draw() {
  21. screenshot();
  22. modifyPixels();
  23. image(screenshot, 0, 0, width, height);
  24. if (save) saveFrame("frames/image-####.tif");
  25. }
  26.  
  27. void screenshot() {
  28. try {
  29. Robot robot_Screenshot = new Robot();
  30. screenshot = new PImage(robot_Screenshot.createScreenCapture
  31. (new Rectangle(displayWidth-w, 170, w, h)));
  32. }
  33. catch (AWTException e) {
  34. }
  35. }
  36.  
  37. void modifyPixels() {
  38. screenshot.loadPixels();
  39. for (int i=0; i<screenshot.pixels.length; i++) {
  40. if ( brightness(screenshot.pixels[i]) > 150) screenshot.pixels[i] &= 0x00FFFFFF;
  41. }
  42. screenshot.updatePixels();
  43. }
  44.  
  45. void keyReleased() {
  46. if (key =='s') save =! save;
  47. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement