flablo
YaBB Newbies
Offline
Posts: 6
Re: Quicktime movies with alpha channel
Reply #2 - Jun 7th , 2007, 10:05am
Yes it does. Sorry I made two posts for different aspects of my project and in the end they converged on topics: http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Programs;action=display;num=1180829325 I'm very sorry about this! I somehow solved the problem anyway: I created separate clips from the original clips'alpha converted as luma, loaded them and applied to the original clips as mask. Well, it worked and now I see right in P3D. The strange thing is: even if I shouldn't need anymore an alpha channel in the original clip (because I apply it expressely through the masking), so they could be RGB clip + mask clip, I saw that it doesn't work this way, the image disappears and sometime flickers in. It works only with ARGB clip + mask clip. Seems strange to me. Anyway having it to work directly with the embedded alpha in the ARGB clip would be faster for sure. OpenGl shoud be even faster and hopefully have a nice quality (I think I could set up antialiasing and other settings from my videocard setup utility) but I have to find a decent workaround for the PGraphics object Well, this is the code by now: import processing.video.*; //buffer for slicing and then masking PGraphics pg; //2 input images PImage slice1; PImage slice2; // input movies + masks Movie myMovie1; Movie myMovie2; Movie myMovie1mask; Movie myMovie2mask; //images for creating mask and kaleidoscope PImage maskImg; // is the mask for the slice (30° of circle) that will be replicated PImage smallbufferImg; int outw, outh; //dimensions of the output/scene int diagfactor; // number used to calculate buffer height int numImg; //mouse position from center int mouseXc, mouseYc; void setup(){ outw=800; outh=600; size(outw,outh); background(0); // create graphic buffer pg = createGraphics(outw,outw, P3D); slice1=loadImage("img1.png"); slice2=loadImage("img2.png"); blackImg=loadImage("800x600black.jpg"); diagfactor=int(sqrt((outh*outh)+(outw*outw))/2); maskImg = loadImage(str(outw/2)+"x"+str(diagfactor)+"mask.jpg"); myMovie1 = new Movie(this, "plant3.mov"); myMovie2 = new Movie(this, "plant2.mov"); myMovie1mask = new Movie(this, "plant3mask.mov"); myMovie2mask = new Movie(this, "plant2mask.mov"); myMovie1.loop(); myMovie2.loop(); myMovie1mask.loop(); myMovie2mask.loop(); } void movieEvent(Movie myMovie) { myMovie.read(); } void draw(){ mouseXc=(mouseX-width/2); mouseYc=-(mouseY-height/2); //TEMPORARY mouse detection to check interactivity/debug if(mousePressed) { slice1=loadImage("img"+str(1+int(random(4)))+".png"); slice2=loadImage("img"+str(1+int(random(4)))+".png"); } // Buffering images and content pg.beginDraw(); pg.background(0); //IMG1 pg.image(slice1,width/2-100,height/2*(1+sin(opacity))); pg.translate(mouseXc+slice2.width,mouseYc+slice2.height); pg.rotate(PI*sin(opacity)/6); //IMG2 pg.image(slice2,mouseXc,mouseYc); pg.image(myMovie1,mouseXc,mouseYc); pg.image(myMovie2,mouseYc,mouseXc); myMovie1.mask(myMovie1mask); myMovie2.mask(myMovie2mask); pg.endDraw(); // cropping/copying buffer to image and masking smallbufferImg=pg.get(outw/2,outh/2,outw/2,diagfactor); smallbufferImg.mask(maskImg); translate(width/2,height/2); //centers the kaleidoscope //first slice and reflection image(smallbufferImg,0,0); pushMatrix(); scale(-1,1); //copy and reflects the slice image(smallbufferImg,0,0); popMatrix(); //draw the other slices for (int i=1; i<6; i=i+1) { rotate(-PI/3); image(smallbufferImg,0,0); pushMatrix(); scale(-1,1); image(smallbufferImg,0,0); popMatrix(); } } don't think about the variable "diagfactor", it's made for the geometry of the kaleidoscope, also mouse detection is just for temporaty test, I'm planning to have cam input and try to detect movement Thanks!! f