How can I get an image to draw transparently?

solokin1

New member
Joined
Feb 27, 2003
Messages
4
Hi,

Thanks for the info on creating a bitmap image in memory, and now I have a question on how to draw an image transparently on a picture box, using drawimage. What I have in mind is something like the following function:

TransBlt(srcImage As Image, srcRect aS Rectangle, destImage As Image, destRect As Rectangle, transColor AS Color)

What would be the source code for this?

Thanks a lot,
Solokin1
 
Well when you make it transparent you will see the back of your picturebox instead of the form itself...

Refer to my post on Transparent Graphic on Top for some info in the area

if you will to make a certain color transparent in the bitmap class you can use the GetPixel method and the Make Transparent method.

Use get pixel to get the color of a pixel that contains the color you wish to make transparent (in most cases GetPixel(1,1) works because the outside of the image is what you wish to make transparent however this doenst always hold true of course

The following code is an example...

Code:
Public Some Sub()
   
Dim b as Bitmap = New Bitmap("myfile")

b.MakeTransparent(b.GetPixel(1,1))

picturebox1.Image = b

not you will not be able to see the form, you should dump the picturebox and use the System.Drawing.Graphics object for that
(i just learned that myself :))

good luck
 
Last edited by a moderator:
Back
Top