• 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

    • Oh man! I can't wait! 😁
    • slowness that result in unproductive, when something was easy fast one click now its basically 2 or 3 clicks and more mouse movement not the end of the world sure but forcing changes for the sake of it for no good reason its one reason why people dont like 11.
    • WhatsApp for Android expands chat themes with 18 new colors by Paul Hill The WhatsApp Beta for Android has just been updated to version 2.25.19.2 (via WABetaInfo) bringing with it 18 new color options, expanding the selection from 20 to 38 colors. This update brings the Android app up to parity with the iOS version, which got this beta update at the start of the month. The expansion of colors will give users greater personalization options for their WhatsApp chats. You can pick the new colors individually per chat or from the settings for every chat, complementing the existing support for various custom backgrounds. How the new chat themes work To set the new colors for individual chats, just open the chat you want to theme, press the three dot menu in the top right and go to themes and change the chat color. To change the theme color across the whole of the app, just go to settings and then select chats and change the chat theme. The new colors are compatible with both light and dark modes and affect the message bubbles. Unlike Messenger where theme changes can be seen by your contact, theme changes in WhatsApp are only visible to the user who applies it. User reception and future outlook Most people running WhatsApp are using the stable version, so you won’t see these new theme colors yet, we will have to wait a bit longer for that. Even if you’re on the beta, the feature may not be available yet as it’s being rolled out. While not a massive change, lots of people like to theme their WhatsApp messages so this change will be welcomed by those that do that. The messaging app scene is very competitive, so this will help Meta retain users on WhatsApp by boosting satisfaction. If you have had a chance to try out the new themes, let us know in the comments what you think!
    • Yup, that thing. Thank you. I found it invaluable for workflow.
    • Windows 11 finally gets a small, but long-requested Windows 10 taskbar feature — and it is not the ability to use small taskbar buttons.
  • Recent Achievements

    • Explorer
      Legend20 went up a rank
      Explorer
    • One Month Later
      jezzzy earned a badge
      One Month Later
    • First Post
      CSpera earned a badge
      First Post
    • One Month Later
      MIR JOHNNY BLAZE earned a badge
      One Month Later
    • Apprentice
      Wireless wookie went up a rank
      Apprentice
  • Popular Contributors

    1. 1
      +primortal
      618
    2. 2
      ATLien_0
      278
    3. 3
      +FloatingFatMan
      179
    4. 4
      Michael Scrip
      150
    5. 5
      Steven P.
      115
  • Tell a friend

    Love Neowin? Tell a friend!