<p>In the Full .NET framework you can use the Color.FromArgb() method to create a new color with alpha blending, like this:</p>

<pre><code>Color blended = Color.FromArgb(alpha, color);
</code></pre>

<p>or</p>

<pre><code>Color blended = Color.FromArgb(alpha, red, green , blue);
</code></pre>

<p>However in the Compact Framework (2.0 specifically), neither of those methods are available, you only get:</p>

<pre><code>Color.FromArgb(int red, int green, int blue);
</code></pre>

<p>and</p>

<pre><code>Color.FromArgb(int val);
</code></pre>

<p>The first one, obviously, doesn't even let you enter an alpha value, but the documentation for the latter shows that "val" is a 32bit ARGB value (as 0xAARRGGBB as opposed to the standard 24bit 0xRRGGBB), so it would make sense that you could just build the ARGB value and pass it to the function.  I tried this with the following:</p>

<pre><code>private Color FromARGB(byte alpha, byte red, byte green, byte blue)
{
    int val = (alpha &lt;&lt; 24) | (red &lt;&lt; 16) | (green &lt;&lt; 8) | blue;
    return Color.FromArgb(val);
}
</code></pre>

<p>But no matter what I do, the alpha blending never works, the resulting color always as full opacity, even when setting the alpha value to 0.</p>

<p>Has anyone gotten this to work on the Compact Framework?</p>

[{'answer_id': 14525, 'author': 'Sören Kuklau', 'author_id': 1600, 'author_profile': 'https://Stackoverflow.com/users/1600', 'pm_score': 2, 'selected': True, 'text': '<p>Apparently, it\'s not quite that simple, but <a href="http://blogs.msdn.com/chrislorton/archive/2006/04/07/570649.aspx" rel="nofollow noreferrer">still possible</a>, if you have Windows Mobile 5.0 or newer.</p>\n'}, {'answer_id': 14529, 'author': 'Adam Haile', 'author_id': 194, 'author_profile': 'https://Stackoverflow.com/users/194', 'pm_score': 0, 'selected': False, 'text': "<blockquote>\n  <p>Apparently, it's not quite that\n  simple, but still possible, if you\n  have Windows Mobile 5.0 or newer.</p>\n</blockquote>\n\n<p>Wow...definitely not worth it if I have to put all that code in (and do native interop!)\nGood to know though, thanks for the link.</p>\n"}, {'answer_id': 199366, 'author': 'Peter Walke', 'author_id': 12497, 'author_profile': 'https://Stackoverflow.com/users/12497', 'pm_score': 1, 'selected': False, 'text': '<p>There is a <a href="http://www.codeplex.com/alphamobilecontrols" rel="nofollow noreferrer">codeplex site</a> out there that seems to do the heavy lifting of com interop for you:</p>\n'}, {'answer_id': 2870347, 'author': 'fede', 'author_id': 345622, 'author_profile': 'https://Stackoverflow.com/users/345622', 'pm_score': 0, 'selected': False, 'text': '<p>i take this code and i add this </p>\n\n<pre><code>device.RenderState.AlphaBlendEnable = true;\ndevice.RenderState.AlphaFunction = Compare.Greater;\ndevice.RenderState.AlphaTestEnable = true;\ndevice.RenderState.DestinationBlend = Blend.InvSourceAlpha;\ndevice.RenderState.SourceBlend = Blend.SourceAlpha;\ndevice.RenderState.DiffuseMaterialSource = ColorSource.Material;\n</code></pre>\n\n<p>in the initialized routine and it work very well, thank you </p>\n'}, {'answer_id': 11091758, 'author': 'Ben Kunz', 'author_id': 1464789, 'author_profile': 'https://Stackoverflow.com/users/1464789', 'pm_score': 0, 'selected': False, 'text': '<p>CE 6.0 does not support alpha blending. WM 5.0 and above do, but not through the .NET CF, you will need to P/Invoke GDI stuff to do so. There are ready-made solutions out there, however, if you are interested i can dig the links out tomorrow at the office. I have to work with CE 6.0 currently so i don\'t have them on my mind.</p>\n\n<p>If you are using CE 6.0 you can use pseudo-transparency by reserving a transparency background color (e.g. ff00ff or something similiarly ugly) and using that in your images for transparent areas. Then, your parent controls must implement a simple interface that allows re-drawing the relevant portion on your daughter controls\' graphics buffer. Note that this will not give you a true "alpha channel" but rather just a hard on-off binary kind of transparency.</p>\n\n<p>It\'s not as bad as it sounds. Take a look at the OpenNETCF ImageButton for starters. If you are going to use this method, i have a somewhat extended version of some simple controls with this technique lying around if you are interested.</p>\n\n<p>One additional drawback is that this technique relies on the parent control implementing a special interface, and the daugther controls using it in drawing. So with closed-source components (i.e. also the stock winforms components) you are out of luck.</p>\n'}]
['https://Stackoverflow.com/questions/14505', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/194/']