• 0

[vb .net] png transparency = black?


Question

ok I have created a png in photoimpact and saved it WITH transparency.

in vb .net, I have set a form to first have the transparent color as "transparent" and then i set it to "magenta" and set the form color as "magenta" thus making the background transparent. however, when I apply a png as the background, any transparent areas comes out as black.

i have also tried using bmps and jpgs with magenta where the transparency shud be and it just shows up as magenta.

how do I get the transparency from the pngs to work in the background image of a form?

Link to comment
https://www.neowin.net/forum/topic/62275-vb-net-png-transparency-black/
Share on other sites

9 answers to this question

Recommended Posts

  • 0

If your problem is that you'd like to have the PNG smoothly blend into the form's current background color, you need not touch the TransparencyKey property of the form. Open up a new form, or remove the TransparencyKey property, add a PictureBox to the form, set the image property to the PNG, and the PNG should blend smoothly into the form.

  • 0
  Quote
The following is a description of the code which can be downloaded below:

Using the GraphicsPath object, we're able to coordinate the outline for the form border. In using the GraphicsPath AddPolygon method we supply several PointF coordinate arguments to initialize myGraphicsPath

The region property is set to a new region with myGraphicsPath in the constructor. You'll need to supply further coordinates in order to create a more advanced border. Using the three points in the code, the window should appear triangular, and by setting the form's FormBorderStyle property to none, the title bar of the application won't appear.

Utilizing the TransparencyKey property of a form is far less efficient than using GDI+

Although this sounds rather complicated, a quick analysis of the three lines of code should prove otherwise:

This was posted by aereux for me. The code he posted is in C#, so i dont know if this will help or not, but here ya go anyway.

The original post was here. It is the 2nd post from the top.

  • 0

bangbang023, what Hyperb0le is offering is what is known as a non-rectangular form. If that, indeed, was what you wanted, then I can easily port the code for you.

However, if what you're attempting is more of a Winamp3-type skin, then no, the code I wrote for Hyperb0le will not help you.

  • 0
  bangbang023 said:
the only problem, hyperbole, is that I only have visual basic .net so I can't open those files :(

Right click on the c# form file (.cs) and open it with notepad. that's all a C# file is :)

And technically you could do a winamp3-style skin with that code, the skinner would just have to define a sh*t load of coordinates.

  • 0

Actually, you couldn't -- at least not with that code. When I refer to Winamp3 skins, I do so with regards to its alpha-blend dropshadow into the desktop. While this is possible using GDI, the code I've provided will only allow you to create a non-rectangular form.

Hyperb0le, while you're correct that a skin can be accomplished (w/o the PNG alpha blend), the hundreds -- if not thousands -- of coordinates do not necessarily have to be specified by the programmer, but instead can be mathematically calculated based upon the image being used to skin the application, and its border.

  • 0

well thank you for all your support but this is getting way complicated lol. I just thought maybe there was a way for a user to inlcude a jpeg or png as a background image on a form and the parts that are transparent in the png or magenta or the jpeg would appear as transparent thus making that part of the form transparent. this is a little beyond me yet, as it seems, so I think I wil lwait until I better adjust to vb .net. thank you for all your help guys.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • I would not mind paying 120 up to 150 dollars in this economy value of the dollar currency if their video game is quite breathtaking and excellent use of my hard earned work money. I think people need to appreciate all the effort workers and time that goes into excellent and worthy video games. Now if only the publishers and companies behind the video games would share the love with the developers those at the bottom of work making such games happen as in increase their money accounts and give them a more richer life that I wish would have happened . But how companies have bad reputation of being $$$ profit greedy I feel sad if there are any developers that feel unappreciated as in no real compensation for all the hours of work they put into a blockbuster hit . Have a great day everyone . Thank you developers engineers and programmers that make superb video games happen . You have my thanksgiving and I hope you really really appreciate my words . With you all about this
    • I guess they use the free version, which doesn't send money to any Russians.
    • True, you can pin it to the Start Menu, but my preference is to pin it to the Taskbar since I am using W11 on a desktop with a large display and a lot of space on the Taskbar.
    • 200 mph. Try going 200 mph with a vehicle on a street in any city in America. Good luck. Yes its speculation but so is the idea that it has been 100% approved by the government. When a new drug is under development it goes through a number of test phases, each of increasing efficacy and safety. I would imagine it is the same in this case. You can similuate real conditions on test roads with other cars and if successful on test roads you move it to the next test phase of testing it on real streets with human assistance if needed. Testing conditions on test roads can never account for all real life situations on real roads. This is what I imagine is happening now. The final test phase.
  • Recent Achievements

    • Week One Done
      Hartej earned a badge
      Week One Done
    • One Year In
      TsunadeMama earned a badge
      One Year In
    • Week One Done
      shaheen earned a badge
      Week One Done
    • Dedicated
      Cole Multipass earned a badge
      Dedicated
    • Week One Done
      Alexander 001 earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      571
    2. 2
      ATLien_0
      186
    3. 3
      +FloatingFatMan
      183
    4. 4
      Skyfrog
      112
    5. 5
      Xenon
      106
  • Tell a friend

    Love Neowin? Tell a friend!