Let's say that we have an ARGB color:
Color argb = Color.FromARGB(127, 69, 12, 255); //Light Urple.
When this is painted on top of an existing color, the colors will blend. So when it is blended with white, the resulting color is Color.FromARGB(255, 162, 133, 255);
The solution should work like this:
Color blend = Color.White;
Color argb = Color.FromARGB(127, 69, 12, 255); //Light Urple.
Color rgb = ToRGB(argb, blend); //Same as Color.FromARGB(255, 162, 133, 255);
What is ToRGB
's implementation?
if you don't need to know this pre-render, you could always use the win32 method of getpixel, I believe.
Note: typing on iPhone in the middle of Missouri with no inet access. Will look up real win32 example and see if there is a .net equivalent.
In case anyone cares, and doesn't want to use the (excellent) answer posted above, you can get the color value of a pixel in .Net via this link MSDN example
It's called alpha blending.
In psuedocode, assuming the background color (blend) always has 255 alpha. Also assumes alpha is 0-255.
note: you probably need to be a bit (more) careful about floating-point/int math and rounding issues, depending on language. Cast intermediates accordingly
Edited to add:
If you don't have a background color with an alpha of 255, the algebra gets alot more complicated. I've done it before and it's a fun exercise left to the reader (if you really need to know, ask another question :).
In other words, what color C blends into some background the same as blending A, then blending B. This is sort of like calculating A+B (which isn't the same as B+A).
I know this is an old thread, but I want to add this: