Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Alpha Compositing and shyts
#2
Assuming you want to blend. That is, alpha is added, and then a percent of a and a percent of b is gained:

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)) continueWink

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


Messages In This Thread
Alpha Compositing and shyts - by KajitiSouls - 2009-12-11, 12:15 AM
Alpha Compositing and shyts - by Nikkey - 2009-12-11, 05:08 AM
Alpha Compositing and shyts - by Stereo - 2009-12-11, 10:07 AM
Alpha Compositing and shyts - by KajitiSouls - 2009-12-11, 04:08 PM
Alpha Compositing and shyts - by Nikkey - 2009-12-11, 05:20 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)