cajinajr
YaBB Newbies
Offline
Posts: 2
Help with masking out parts of a movie
Apr 5th , 2007, 7:57pm
So I took the code from the examples that people sent me last time and used it for trying to mask my video. Now processing is giving me some kind of "NegativeArraySizeException" error. When I try to change the size of the mask...it then gives me an error that looks like "the PImage used with mask() must be the same size as the applet." I'm stuck and don't know what to do! Please help! Here's my code: import processing.video.*; //PImage img; Movie doorMovie; PImage masked; color cp; int xPos, yPos; boolean doCopy = false; int maskW, maskH; int[] maskArray; void setup() { size(320, 240); //img = loadImage("pic1.jpg"); doorMovie = new Movie(this, "The Shining Door-small.mpg"); doorMovie.loop(); maskW = 100; maskH = 230; int arraySize = maskW * maskH; maskArray = new int[arraySize]; createMaskArray(); xPos = width/2; yPos = height/2; masked = new PImage(maskW, maskH); copyApplyMask(); } void draw() { //image(img, 0, 0); image(doorMovie, 0, 0); background(0); image(masked, xPos - maskW/2, yPos - maskH/2); } //Called every time a new frame is available to read void movieEvent(Movie m) { m.read(); } void mouseMoved() { if (!(mouseX < maskW/2 || mouseX > width - maskW/2)) { xPos = mouseX; doCopy = true; } if (!(mouseY < maskH/2 || mouseY > height - maskH/2)) { yPos = mouseY; doCopy = true; } if (doCopy) copyApplyMask(); doCopy = false; } void createMaskArray() { background(0); fill(255); rectMode(CORNER); rect(0, 0, maskW, maskH); loadPixels(); for (int x = 0; x < maskW; x++) { for (int y = 0; y < maskH; y++) { maskArray[x + (y * maskW)] = pixels[x + (y * width)]; } } updatePixels(); } void copyApplyMask() { // this is what andreas was doing translated to Processing 124 masked = doorMovie.get(xPos - maskW/2, yPos - maskH/2, maskW, maskH); masked.mask(maskArray); } Thanks for any kind of help I can get!!