Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted (edited)

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 doens't always hold true of course

 

The following code is an example...

 

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

Edited by divil
i'm not lazy i'm just resting before i get tired.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...