Advertisement
xeromino

videoStuff

Mar 28th, 2017
218
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import processing.video.*;
  2.  
  3. Movie movie;
  4.  
  5. void setup() {  
  6.   size(1280,720);
  7.   background(150);
  8.   movie = new Movie(this, "beyonce.mp4");
  9.   movie.play();
  10. }
  11.  
  12. void draw() {
  13.   if (movie.available()) {  
  14.     movie.read();
  15.     image(makeTooBrightColorTransparent(movie, 100), 0, 0);
  16.   }
  17. }
  18.  
  19. // answer to my question on forum.Processing.org/two/discussion/21653/how-to-make-a-pixel-transparent
  20. // GoToLoop (2017-Mar-28)
  21.  
  22. PImage makeTooBrightColorTransparent( PImage img, int bright) {
  23.   img.loadPixels();
  24.   color colors[] = img.pixels, len = colors.length;
  25.   for (int i = 0; i < len; ++i) {
  26.     color c = colors[i];
  27.     if (brightness(c) > bright) {
  28.       colors[i] = c & ~PImage.ALPHA_MASK;
  29.     }
  30.   }
  31.   img.updatePixels();
  32.   return img;
  33. }
  34.  
  35. void mouseReleased() {
  36.   save(random(9999)+".png");
  37. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement