Results 1 to 2 of 2

Thread: Alpha channel PNG through form not alpha channeling?

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2011
    Posts
    8

    Alpha channel PNG through form not alpha channeling?

    I have a simple VB.NET 2008 Express program. I put a picture box on a form, set the picture box to a PNG with an alpha channel and set the form to be transparent. It mostly works except where the PNG starts its alpha channel or anti-aliasing or lending. Not sure exactly what. I don't want the ugly borders. In the attachment you'll see the first image is over the desktop running, the second (over a red background) is what it would look like doing the blending properly, the 3rd image is the transparent background for reference and the 4th is my form in VB.net. How do I make the blending/alpha channel work? The first image should be similar to the second (red) one with no grey background where the drop shadow is. Any know how to fix this? I need it to blend with the background it is over which is the desktop. Has this been improved in VB.NET 2010 or 2012? I'm under Windows 7 64bit.

    Name:  error.jpg
Views: 1205
Size:  33.9 KB
    Last edited by jayw121; Mar 6th, 2015 at 02:22 AM.

  2. #2
    PowerPoster boops boops's Avatar
    Join Date
    Nov 2008
    Location
    Holland/France
    Posts
    3,129

    Re: Alpha channel PNG through form not alpha channeling?

    Windows Forms can not render partial transparency to the Desktop. You can make parts of a form totally transparent with its TransparencyKey or Region properties while all other pixels remain opaque; or you can make the whole form partly transparent using its Opacity property. This limitation has nothing to do with your version of VS or of Windows. It's just the way Windows Forms was made.

    There are other technologies that do allow alpha blending images with the Desktop. One is them is the Layered Window, about which you can find information and code here. There are also several entries in the Code Project. However, a Layered Window is not a Form: it can not host controls.

    Fortunately, Microsoft realized that people weren't satisfied with the limitations of Forms some while back, and provided WPF to solve them. WPF is part of the DotNet Framework, and it has been available in Visual Studio since VS2008 including Express editions. The snag is that WPF is such a huge topic that it seems overwhelming. But you can take advantage of WPF without knowing all that much about it: see the "Shaped Form" link in my signature below. It gives you step-by-step instructions for placing one alpha-blended image (plus 1 WPF Button) over the Desktop, starting from a Form. It wouldn't be hard to adapt it to show a group of WPF Buttons, each with its own alpha-blended image. You code the button click events the same way as for Forms. If you want to try it and need suggestions, just post here.

    BB

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width