Making it happen
Destination Alpha in Alpha Blending
Everyone knows that c0 = cd*(1-a)+cs*a for color channels, but how do you compute the final alpha channel ? Using the same equation means a0=ad*(1-a)+a*a that may not be what you would expect, for example if you have full opaque destination you may end up with a translucent image a0 < 1.
By reverse engineering of Paint.NET (and Photoshop) I came with a0 = ad*(1-a)+1*a, that is an additive blending for alpha. While I have found no real explanation why to use this formula, I had to. Oh and BTW, ActionScript’s BitmapData.copyPixels blends like crap, you’d better code your own alpha blending.
Update: Well, the correct alpha blending equations are: a0 = a+ad*(1-a) and c0 = (cd*ad*(1-a)+cs*a) / a0, from Wikipedia.
| Print article | This entry was posted by andrei on August 29, 2008 at 12:30 pm, and is filed under Uncategorized. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |
