Jump to content
  • Advertisement
Sign in to follow this  
Templarian

[.NET] Transparent Picturebox

This topic is 4514 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Okay image_1 (picturebox) is over image_2 (picturebox). image_1 has a .png with a transparent middle. www.templarian.com/misc/gpwiki/box.png image_2 is a random .png image repersenting a test background. This seems so simple, but i've spend the last 4 hours trying to find it out to no avail. setstyle opaque to true seems to be blocked. Q. How do I make the image_2 seen though the middle of image_1. Thanks. Someone told me to come here after he failed to find the answer out. It seems so simple it was easy in VB6 and VB.Net is newer so its probably something dumb I overlooked.

Share this post


Link to post
Share on other sites
Advertisement
Making a control transparent is really the wrong approach to doing graphics. If you are going to be doing simple graphics in .Net, Your probably going to want to look into GDI+. It will do just about any 2D you want. For a complex render engine you'll probably want something more powerfull than GDI+

Share this post


Link to post
Share on other sites
Strange, I've never had a problem using transparency in .NET controls. As long as you draw the background image first, then box.png you should be fine.

Can you post the code or a screenshot of what it looks like?

Share this post


Link to post
Share on other sites
Not to sound newbish but what do you mean draw the backgroundimage you mean set a backgroundimage... ?

BTW is it possible to create my own control that just has .image .size .location becuase that way I can make it not protected and change the background to opaque (or am i thinking of this wrong).

Share this post


Link to post
Share on other sites
Here is the problem with .NET control's transparency. When windows draws a control and decides that something is transparent, it then takes the PARENT'S contents (parent is the control to which your control belongs to - like the form on which the image is on) and draws that part of it.

So, if you had two image controls, if you have transparency in them, the part that is transparent will be filled in with the parent's control - ie. the form that they are on. Even if the two images overlap, they will not display one another below because they are both the child controls of the form they are on.

... and no, there is no way around this. Use GDI+ and override the Paint event.

I hope you understand, I am not so good in explaining... :(

Share this post


Link to post
Share on other sites
Yea... I understand because i already knew it. I was naming its parent ealier so i could see though it but yea logically my design has multiple images over eachother at one time.

... this is going to take a lot more code than my VB6 version took. arg.

Thanks everyone.

Just for a random question what is the dumb point of setstyle if it cant be used (it can only be used on the form itself from what i saw and thats just doesnt make sense in itself)?


'edit Okay are there control arrays in .net MS isn't very smart. Still need the above question answered.

[Edited by - Templarian on July 7, 2006 2:24:46 PM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!