2009-12-11, 05:08 AM
Assuming you want to blend. That is, alpha is added, and then a percent of a and a percent of b is gained:
This blows up if both alphas are zero, btw. Shouldn't matter, as zeroes shouldn't be added anyway (if ((a1 == 0) && (a2 == 0)) continue
What are you really trying to do though? There are a ton of ways to blend them, so uh.
Code:
double tot = a1 + a2;
newImage[offset + j*4 + 3] = (byte)a0; //alpha result
newImage[offset + j*4] = (byte)(r1 * a1/tot + r2 * a2/tot);
newImage[offset + j*4] = (byte)(g1 * a1/tot + g2 * a2/tot);
newImage[offset + j*4] = (byte)(b1 * a1/tot + b2 * a2/tot);This blows up if both alphas are zero, btw. Shouldn't matter, as zeroes shouldn't be added anyway (if ((a1 == 0) && (a2 == 0)) continue

What are you really trying to do though? There are a ton of ways to blend them, so uh.

