Teen Programmers Unite  
 

 

Return to forum top

VB 5.0 bmp transparency. How?

Posted by markbell [send private reply] at July 09, 2002, 07:12:03 AM

Was wondering how to place a .bmp picture over the top of another .bmp with the top one having a transparent colour.

Posted by buzgub [send private reply] at July 09, 2002, 08:04:16 AM

The normal method is with a transparency mask. You have your main picture, in many colours, and another picture in two colours, one of which means "this pixel is transparent".
You use the BitBlt api call to copy the first picture in, then copy the transparency mask over it doing transparency things. This is moderately efficient.

The other method is to make two image boxes, use a format that supports transparency(GIF?), load the pictures into the boxes, and place one box in front of the other. Fiddle with ordering if you need to. This is inefficient.

All of this stuff should be explained by a games creation tutorial or book.

Posted by eXorcus [send private reply] at July 09, 2002, 08:40:04 AM

Bitmap transparency is actually pretty simple. I usually create a sub like BitBltTrans(hdcSrc, hdcDest, x, y, etc...
and have both BitBlt operations take place inside. Check out this tutorial, it should explain everything:
http://www.winprog.org/tutorial/transparency.html

Posted by markbell [send private reply] at July 14, 2002, 04:51:51 AM

Thanks very much for that. Will give it a try.

Posted by Brok3n_Link [send private reply] at July 22, 2002, 12:45:53 AM

eXorcus good idea

but why not use the AlphaBlending.dll??
I know it means another file to carry around, but it works an absolute treat, it reallt does. I've used it heaps when making skinnable apps and other cool effects plus some games... It's simple once you know wtf you're doing:
a link to an AlphaBlending example:
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=25859&ln...

brok3n Link
brok3n@iinet.net.au

Posted by eXorcus [send private reply] at July 23, 2002, 10:54:42 AM

Hey wicked man!

I had no idea such a lib existed...Screw masks! =P

I will mess around with this and see if it really helps...I'm currently toying with a project that I plan on making skinnable, this would be handy methinks. Thanks

You must be logged in to post messages and see which you have already read.

Log on
Username:
Password:
Save for later automatic logon

Register as a new user
 
Copyright TPU 2002. See the Credits and About TPU for more information.