How do I add an alpha channel to a video?
in
Core Library Questions
•
2 years ago
Hi I tried to add an alpha channel to a video in this example but it doesn't seem to work. Just curious what I have to do to add an alpha channel to a video. I thought I would see the red rectangle below the video here. Ultimately I want to change transparency between two videos. Any pointers?
Thanks,
// load video library
import processing.video.*;
Movie myMovie;
int numPixels;
void setup() {
size(640, 480, P2D);
background(0);
// Load and play the video in a loop
myMovie = new Movie(this, "station.mov");
myMovie.loop();
}
void movieEvent(Movie myMovie) {
myMovie.read();
numPixels=myMovie.width*myMovie.height;
myMovie.loadPixels();
for(int i=0; i<numPixels; i++) {
myMovie.pixels[i]=(myMovie.pixels[i]&0x00FFFFFF)|0x1F000000;
}
myMovie.updatePixels();
}
void draw() {
fill(255,0,0);
rect(0,0,100,100);
image(myMovie, 0, 0);
}
Thanks,
// load video library
import processing.video.*;
Movie myMovie;
int numPixels;
void setup() {
size(640, 480, P2D);
background(0);
// Load and play the video in a loop
myMovie = new Movie(this, "station.mov");
myMovie.loop();
}
void movieEvent(Movie myMovie) {
myMovie.read();
numPixels=myMovie.width*myMovie.height;
myMovie.loadPixels();
for(int i=0; i<numPixels; i++) {
myMovie.pixels[i]=(myMovie.pixels[i]&0x00FFFFFF)|0x1F000000;
}
myMovie.updatePixels();
}
void draw() {
fill(255,0,0);
rect(0,0,100,100);
image(myMovie, 0, 0);
}
1