|
-
Nov 18th, 2011, 12:07 AM
#1
Thread Starter
Junior Member
Per-Pixel Alpha Transparency?
I'm trying to create a program using Visual Basic .NET 2010 that alters the use of my media keys - Volume up, Volume down, Play, etc. All of the example I have found don't seem to compile quite correctly in 2010. Don't get me wrong they run fine and look exactly as specified but the problem is that the form cannot be edited because it claims the designer code is ill-formatted or something along the lines of that.
Can anybody possibly spare a project or form that has perpixel alpha transperancy?
The only thing i want to do is show an overlayed png that has an alpha channel, on the desktop. The form border style will most certainly be "NoBorder"
Thanks!
Last edited by Maximus1001; Nov 19th, 2011 at 08:09 AM.
-
Nov 18th, 2011, 04:39 AM
#2
Re: Per-Pixel Alpha Transperancy?
 Originally Posted by Maximus1001
I'm trying to create a program using Visual Basic .NET 2010 that alters the use of my media keys - Volume up, Volume down, Play, etc. All of the example I have found don't seem to compile quite correctly in 2010. Don't get me wrong they run fine and look exactly as specified but the problem is that the form cannot be edited because it claims the designer code is ill-formatted or something along the lines of that.
Can anybody possibly spare a porject or form that has perpixel alpha transperancy?
The only thing i want to do is show an overlayed png that has an alpha channel, on the desktop. The form border style will most certainly be "NoBorder"
Thanks!
If the Designer is rejecting your form, why not post the code? Maybe we can spot what is going wrong. If you have altered the Designer.vb form, try starting a new form and copy the code across. Does it still give problems?
As for "sparing" a porject... Maybe you are familiar with the CodeProject article by Rui Lopes (Per Pixel Alpha Blend in C#). It's not hard to translate the code into VB.Net, e.g. with an online translator and it works in VB2010, at least with 32-bit WinXP and Vista. Do you already have the necessary Win32 API functions? I have my own VB.Net version but it's embedded with other code so it would take some time to sort out.
BB
-
Jun 26th, 2013, 05:04 AM
#3
New Member
Re: Per-Pixel Alpha Transparency?
I know this question is old, but I want to post this here because I haven't had much luck finding a strait forward answer for this.
I hope other people find this useful.
Code:
Public Shared Function AlphaBlend(ByVal ForeGround As Color, ByVal BackGround As Color) As Color
If ForeGround.A = 0 Then Return BackGround
If BackGround.A = 0 Then Return ForeGround
If ForeGround.A = 255 Then Return ForeGround
Dim Alpha As Integer = CInt(ForeGround.A) + 1
Dim B As Integer = Alpha * ForeGround.B + (255 - Alpha) * BackGround.B >> 8
Dim G As Integer = Alpha * ForeGround.G + (255 - Alpha) * BackGround.G >> 8
Dim R As Integer = Alpha * ForeGround.R + (255 - Alpha) * BackGround.R >> 8
Dim A As Integer = ForeGround.A
If BackGround.A = 255 Then A = 255
If A > 255 Then A = 255
If R > 255 Then R = 255
If G > 255 Then G = 255
If B > 255 Then B = 255
Return Color.FromArgb(Math.Abs(A), Math.Abs(R), Math.Abs(G), Math.Abs(B))
End Function
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|