• 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.