| View previous topic :: View next topic |
| Author |
Message |
angerist Grandmaster Cheater Supreme
Reputation: 0
Joined: 18 Jun 2007 Posts: 1011 Location: Australia.
|
Posted: Thu Aug 06, 2009 6:27 am Post subject: VB.NET Homework problem :S |
|
|
Well I have an assignment for General Programming for school. Our assignment is to make a game. I've thought up a game called target practice where you use angles to shoot the target that pops up in random spots on the form. But it seems that I've got stuck way earlyier then I expected to.
If you look at the screenshot the picture of the man ("Kevin Rudd LOL") is transparent but the problem is the bits that are transparent go right back to the grey form. When I want them to go to the picture box behind kevin rudd. I hope that makes sense. You'll understand when you see the screenshot.
I forgot to mention that grey is the transparent key on the form.
Please shed some knowledge on this subject
Screenie:
_________________
|
|
| Back to top |
|
 |
Snootae Grandmaster Cheater
Reputation: 0
Joined: 16 Dec 2006 Posts: 969 Location: --->
|
Posted: Thu Aug 06, 2009 6:49 am Post subject: |
|
|
short answer, vb says no
i have tested this before, it doesnt like the fact that there are controls underneath, if its set to transperant it just uses the form colour, so id say you need to photoshop that sucker
_________________
|
|
| Back to top |
|
 |
shhac Expert Cheater
Reputation: 0
Joined: 30 Oct 2007 Posts: 108
|
Posted: Thu Aug 06, 2009 12:16 pm Post subject: |
|
|
VB hates alpha channels
|
|
| Back to top |
|
 |
dnsi0 I post too much
Reputation: 0
Joined: 04 Jan 2007 Posts: 2674
|
Posted: Thu Aug 06, 2009 4:36 pm Post subject: |
|
|
| that's why you should use directdraw or direct3d with vb. It runs pretty well (surprisingly). (You should use Direct3D since directdraw doesn't support alpha channels or at least I can't find them...)
|
|
| Back to top |
|
 |
angerist Grandmaster Cheater Supreme
Reputation: 0
Joined: 18 Jun 2007 Posts: 1011 Location: Australia.
|
Posted: Fri Aug 07, 2009 1:55 am Post subject: |
|
|
So what would be the most logical way around this. It's really difficult to get the gradient on the target to match the gradient on the background image so photoshop isn't really an option. Some snippets would be really helpful but I know that's a lot to ask.
EDIT: I've been doing some research I found this.
http://msdn.microsoft.com/en-us/library/dd183370%28VS.85%29.aspx
| Quote: | BitBlt Function
The BitBlt function performs a bit-block transfer of the color data corresponding to a rectangle of pixels from the specified source device context into a destination device context. |
_________________
|
|
| Back to top |
|
 |
dnsi0 I post too much
Reputation: 0
Joined: 04 Jan 2007 Posts: 2674
|
Posted: Fri Aug 07, 2009 10:17 am Post subject: |
|
|
| angerist wrote: | So what would be the most logical way around this. It's really difficult to get the gradient on the target to match the gradient on the background image so photoshop isn't really an option. Some snippets would be really helpful but I know that's a lot to ask.
EDIT: I've been doing some research I found this.
http://msdn.microsoft.com/en-us/library/dd183370%28VS.85%29.aspx
| Quote: | BitBlt Function
The BitBlt function performs a bit-block transfer of the color data corresponding to a rectangle of pixels from the specified source device context into a destination device context. |
|
Ahh Yes, GDI32. I wrote a class to use this but lost it... I'm pretty sure you can find in on planetsourcecode.
|
|
| Back to top |
|
 |
sven3107 Expert Cheater
Reputation: 0
Joined: 04 Feb 2009 Posts: 118 Location: Belgium
|
Posted: Fri Aug 07, 2009 10:26 am Post subject: |
|
|
I know that C# has a class "System.Drawing.Drawing2D.ColorBlend".
I doubt it will be of any use though. :\
|
|
| Back to top |
|
 |
Polynomial Grandmaster Cheater
Reputation: 5
Joined: 17 Feb 2008 Posts: 524 Location: Inside the Intel CET shadow stack
|
Posted: Sat Aug 08, 2009 10:55 am Post subject: |
|
|
Best thing to do is use a tranparent PNG. Load the image up in Photoshop, select the grey background section, then delete it. It'll show up as transparency. Go to File -> Save As, set the file type to PNG. Make sure that you enable transparency, leave interlacing as none.
Make sure you set the background colour of the picture box to Transparent.
|
|
| Back to top |
|
 |
angerist Grandmaster Cheater Supreme
Reputation: 0
Joined: 18 Jun 2007 Posts: 1011 Location: Australia.
|
Posted: Sun Aug 09, 2009 1:27 am Post subject: |
|
|
Dude the image isn't grey. The form colour is grey. The image already is transparent.
_________________
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Sun Aug 09, 2009 2:06 am Post subject: |
|
|
Using the .NET drawing class is probably the smartest way in this case... but I've never used GDI+ so I'm not sure if there's a nice, native way of ignoring a certain color.
There seems to be a method for locking the bits to the image though. I suppose you can manually iterate through each pixel and ignore what should be transparent, but this may be overkill and out of your scope.
Looking through MSDN though it looks like you should be able to just create a Bitmap object, set the PixelFormat to 32 ARGB, set the transparency key with the MakeTransparent method and draw it.
|
|
| Back to top |
|
 |
angerist Grandmaster Cheater Supreme
Reputation: 0
Joined: 18 Jun 2007 Posts: 1011 Location: Australia.
|
Posted: Wed Aug 12, 2009 4:46 am Post subject: |
|
|
I'll look into that. Even though almost everything is out of my scope. I'm not a big fan of vb.net. But yeah I'll keep researching. Any snippets that you can give me would be nice .
_________________
|
|
| Back to top |
|
 |
Luigi Grandmaster Cheater Supreme
Reputation: 1
Joined: 24 Mar 2008 Posts: 1082
|
Posted: Wed Aug 19, 2009 2:26 pm Post subject: |
|
|
| Snootae wrote: | short answer, vb says no
i have tested this before, it doesnt like the fact that there are controls underneath, if its set to transperant it just uses the form colour, so id say you need to photoshop that sucker | You most certainly can use transparent. I made a useless program that was completely transparent excluding text. It's just like glass (HURR DURR)
|
|
| Back to top |
|
 |
|