• 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

    • the yellow rabbits are not trying seaweed
    • LibreWolf 139.0.4-1 by Razvan Serea LibreWolf is an independent “fork” of Firefox, with the primary goals of privacy security and user freedom. It is the community run successor to LibreFox. LibreWolf is designed to increase protection against tracking and fingerprinting techniques, while also including a few security improvements. This is achieved through our privacy and security oriented settings and patches. LibreWolf also aims to remove all the telemetry, data collection and annoyances, as well as disabling anti-freedom features like DRM. LibreWolf features: Latest Firefox — LibreWolf is compiled directly from the latest build of Firefox Stable. You will have the the latest features, and security updates. Independent Build — LibreWolf uses a build independent of Firefox and has its own settings, profile folder and installation path. As a result, it can be installed alongside Firefox or any other browser. No phoning home — Embedded server links and other calling home functions are removed. In other words, minimal background connections by default. User settings updates Extensions firewall: limit internet access for extensions. Multi-platform (Windows/Linux/Mac/and soon Android) Community-Driven Dark theme (classic and advanced) LibreWolf privacy features: Delete cookies and website data on close. Include only privacy respecting search engines like DuckDuckGo and Searx. Include uBlockOrigin with custom default filter lists, and Tracking Protection in strict mode, to block trackers and ads. Strip tracking elements from URLs, both natively and through uBO. Enable dFPI, also known as Total Cookie Protection. Enable RFP which is part of the Tor Uplift project. RFP is considered the best in class anti-fingerprinting solution, and its goal is to make users look the same and cover as many metrics as possible, in an effort to block fingerprinting techniques. Always display user language as en-US to websites, in order to protect the language used in the browser and in the OS. Disable WebGL, as it is a strong fingerprinting vector. Prevent access to the location services of the OS, and use Mozilla's location API instead of Google's API. Limit ICE candidates generation to a single interface when sharing video or audio during a videoconference. Force DNS and WebRTC inside the proxy, when one is being used. Trim cross-origin referrers, so that they don't include the full URI. Disable link prefetching and speculative connections. Disable disk cache and clear temporary files on close. Disable form autofill. Disable search and form history...and more. Notes: To receive automatic updates, you may refer to the unofficial LibreWolf-WinUpdater that employs a scheduled task to accomplish the same. Download: LibreWolf 64-bit | Portable 64-bit |~100.0 MB (Open Source) Download: LibreWolf 32-bit | Portable 32-bit | Other Operating Systems Links: LibreWolf Home Page | Addons | Screenshot | Reddit Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • I have Copilot on an A8-7410 APU (more than one), an A10-5745M APU, an A12-9720P APU, and a PRO A12-9800B APU. Some of the machines with these APUs do not have 16GB RAM.
    • So the 16 GB minimum memory requirement isn't to be taken seriously? The WU installer evidently took it seriously, at least in my case. https://www.techpowerup.com/31...lot-and-windows-ai-features
  • Recent Achievements

    • One Month Later
      POR2GAL4EVER earned a badge
      One Month Later
    • One Year In
      Orpheus13 earned a badge
      One Year In
    • One Month Later
      Orpheus13 earned a badge
      One Month Later
    • Week One Done
      Orpheus13 earned a badge
      Week One Done
    • Week One Done
      serfegyed earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      560
    2. 2
      ATLien_0
      255
    3. 3
      +Edouard
      163
    4. 4
      +FloatingFatMan
      157
    5. 5
      Michael Scrip
      109
  • Tell a friend

    Love Neowin? Tell a friend!