• 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

    • LibreOffice narrows gap with Microsoft Office in 25.8 Beta 1 by David Uzondu The Document Foundation has released LibreOffice 25.8 Beta 1 for public testing on Linux, macOS, and Windows. This is the second pre-release for the 25.8 cycle and the foundation says that the final, stable version of LibreOffice 25.8 is expected to land at the end of August 2025. Starting off with Writer, LibreOffice's Word, the developers have finally addressed some long-standing annoyances, including a new command to easily insert a paragraph break right before a table. This beta also introduces a useful privacy feature in its Auto-Redact tool, letting you strip all images from a document with a single option. To use it, go to Tools and select the Auto-Redact option: The application has improved its ability to handle different languages for punctuation, preventing mix-ups in multilingual documents. Other notable improvements have also been made. A new hyphenation rule lets you choose to prevent a word from splitting at the end of a page, moving the whole line to the next page instead. Microsoft Word has had this feature for years now. The Navigator now displays a handy tooltip with word and character counts for headings and their sub-outlines. Scrolling behavior when selecting text has been improved, making it less erratic. A new command with a keyboard shortcut was added for converting fields into plain text. Calc gets a lot of new functions that bring it closer to its competitors like Excel, including TEXTSPLIT, VSTACK, and WRAPROWS. Impress now properly supports embedded fonts in PPTX files, which should reduce headaches when sharing presentations with PowerPoint users. Alongside these additions, the project is also cleaning house; support for Windows 7, 8, and 8.1 has been completely dropped. There are also smaller UI tweaks across the suite, like allowing a single click to enter rotation mode for objects in Writer and Calc. macOS users get better integration, with proper support for native full screen mode and new window management features from the Sequoia update. In terms of performance, the team has optimized everything from loading huge DOC files and XLSX spreadsheets with tons of conditional formatting to simply switching between sheets in Calc. These improvements should be noticeable, especially when working with complex documents. A new application-wide "Viewer mode" has also been implemented, which opens all files in a read-only state for quick, safe viewing. On a related note, The Document Foundation has joined efforts by the likes of KDE to encourage Windows 10 users to switch to Linux. Also, you might have heard that Denmark, in a bid to lessen its reliance on Microsoft, has decided to make a full switch to LibreOffice, with plans to begin phasing out Office 365 in certain ministries as early as next month. If you're interested in this release, you can read the full release notes and download the binaries for your platform: Windows, macOS (Intel | Apple Silicon), or Linux (DEB | RPM). You can also get the latest stable version from our software stories page.
    • Until it can be used 100% offline (ie: PST file support or equiv) not even considering it. I'll jump to Thunderbird first which has gotten a LOT better since the last time I looked at it.
  • Recent Achievements

    • Explorer
      Case_f went up a rank
      Explorer
    • Conversation Starter
      Jamie Smith earned a badge
      Conversation Starter
    • First Post
      NeoToad777 earned a badge
      First Post
    • Week One Done
      JoeV earned a badge
      Week One Done
    • One Month Later
      VAT Services in UAE earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      545
    2. 2
      ATLien_0
      227
    3. 3
      +FloatingFatMan
      160
    4. 4
      Michael Scrip
      113
    5. 5
      +Edouard
      104
  • Tell a friend

    Love Neowin? Tell a friend!