We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
blend? (Read 625 times)
blend?
May 20th, 2005, 8:41pm
 
Code:

PImage one,two;
void setup(){
size(640,480,P3D);
one = loadImage("import (0).jpg");
two = loadImage("import (1).jpg");
}
void draw(){
background(one);
blend(two,0,0,two.width,two.height,0,0,one.width,one.height,BLEND);
}

If I use any other mode than BLEND it works, this is really annoying because I need to do some image blending. Am I typing this in wrong or what? All blend seems to do in BLEND mode is write over the old image, regardless of what drawing mode I use (I need to use it in OPENGL, the almighty turbo mode).

Update: I'm using this code to bypass the lack of a functioning blend() function:
Code:

PImage blendd(PImage one, PImage two){
for (int iy = 0; iy < one.height; iy++){
for (int ix = 0; ix < one.width; ix++){
color c1 = one.pixels[ix + iy * one.width];
color c2 = two.pixels[ix + iy * two.width];
int r1=c1>>16&0xff;
int g1=c1>>8&0xff;
int b1=c1&0xff;
int r2=c2>>16&0xff;
int g2=c2>>8&0xff;
int b2=c2&0xff;
one.pixels[ix + iy * one.width] = color ((r1+r2)>>1,(g1+g2)>>1,(b1+b2)>>1);
}
}
one.updatePixels();
return one;
}

It doesn't work with open gl which I can live with since I'm rendering frames at a time with this one. Still doesn't explain why blend() doesn't work with BLEND though.
Page Index Toggle Pages: 1