<p>Let's say that we have an ARGB color:</p>

<pre><code>Color argb = Color.FromARGB(127, 69, 12, 255); //Light Urple.
</code></pre>

<p>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 <code>Color.FromARGB(255, 162, 133, 255);</code></p>

<p>The solution should work like this:</p>

<pre><code>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);
</code></pre>

<p>What is <code>ToRGB</code>'s implementation?      </p>

[{'answer_id': 2789, 'author': 'Louis Brandy', 'author_id': 2089740, 'author_profile': 'https://Stackoverflow.com/users/2089740', 'pm_score': 5, 'selected': True, 'text': '<p>It\'s called <a href="http://en.wikipedia.org/wiki/Alpha_compositing" rel="noreferrer">alpha blending</a>.</p>\n\n<p>In psuedocode, assuming the background color (blend) always has 255 alpha. Also assumes alpha is 0-255.</p>\n\n<pre><code>alpha=argb.alpha()\nr = (alpha/255)*argb.r() + (1 - alpha/255)*blend.r()\ng = (alpha/255)*argb.g() + (1 - alpha/255)*blend.g()\nb = (alpha/255)*argb.b() + (1 - alpha/255)*blend.b()\n</code></pre>\n\n<p><em>note: you probably need to be a bit (more) careful about floating-point/int math and rounding issues, depending on language. Cast intermediates accordingly</em></p>\n\n<p><strong>Edited to add:</strong></p>\n\n<p>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 :). </p>\n\n<p>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).</p>\n'}, {'answer_id': 3129, 'author': 'Matt Dawdy', 'author_id': 232, 'author_profile': 'https://Stackoverflow.com/users/232', 'pm_score': 2, 'selected': False, 'text': '<p>if you don\'t need to know this pre-render, you could always use the win32 method of getpixel, I believe. </p>\n\n<p>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.</p>\n\n<p>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 <a href="http://msdn.microsoft.com/en-us/library/system.drawing.bitmap.getpixel.aspx" rel="nofollow noreferrer">MSDN example</a></p>\n'}, {'answer_id': 17318104, 'author': 'Paul Ishak', 'author_id': 1532865, 'author_profile': 'https://Stackoverflow.com/users/1532865', 'pm_score': 2, 'selected': False, 'text': '<p>I know this is an old thread, but I want to add this:</p>\n\n<pre><code>Public Shared Function AlphaBlend(ByVal ForeGround As Color, ByVal BackGround As Color) As Color\n    If ForeGround.A = 0 Then Return BackGround\n    If BackGround.A = 0 Then Return ForeGround\n    If ForeGround.A = 255 Then Return ForeGround\n    Dim Alpha As Integer = CInt(ForeGround.A) + 1\n    Dim B As Integer = Alpha * ForeGround.B + (255 - Alpha) * BackGround.B &gt;&gt; 8\n    Dim G As Integer = Alpha * ForeGround.G + (255 - Alpha) * BackGround.G &gt;&gt; 8\n    Dim R As Integer = Alpha * ForeGround.R + (255 - Alpha) * BackGround.R &gt;&gt; 8\n    Dim A As Integer = ForeGround.A\n\n    If BackGround.A = 255 Then A = 255\n    If A &gt; 255 Then A = 255\n    If R &gt; 255 Then R = 255\n    If G &gt; 255 Then G = 255\n    If B &gt; 255 Then B = 255\n\n    Return Color.FromArgb(Math.Abs(A), Math.Abs(R), Math.Abs(G), Math.Abs(B))\nEnd Function\n\npublic static Color AlphaBlend(Color ForeGround, Color BackGround)\n{\n    if (ForeGround.A == 0)\n        return BackGround;\n    if (BackGround.A == 0)\n        return ForeGround;\n    if (ForeGround.A == 255)\n        return ForeGround;\n\n    int Alpha = Convert.ToInt32(ForeGround.A) + 1;\n    int B = Alpha * ForeGround.B + (255 - Alpha) * BackGround.B &gt;&gt; 8;\n    int G = Alpha * ForeGround.G + (255 - Alpha) * BackGround.G &gt;&gt; 8;\n    int R = Alpha * ForeGround.R + (255 - Alpha) * BackGround.R &gt;&gt; 8;\n    int A = ForeGround.A;\n\n    if (BackGround.A == 255)\n        A = 255;\n    if (A &gt; 255)\n        A = 255;\n    if (R &gt; 255)\n        R = 255;\n    if (G &gt; 255)\n        G = 255;\n    if (B &gt; 255)\n        B = 255;\n\n    return Color.FromArgb(Math.Abs(A), Math.Abs(R), Math.Abs(G), Math.Abs(B));\n}\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/2780', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/45/']