[RESOLVED] Pictures on top of pictures
Is there anyway for me to cut out an object instead of having it in a box? I have a picture of a person with his had raised and then a second picture of a sword. When i press a button I can get the sword to appear in his hand, but the white background of the swords picture box, cuts off the hand of the person. Is there anyway to cut out the sword or let the background show through the swords background?
Thanks
Re: Pictures on top of pictures
Sorry, I deleted my post, I thought this thread was in the VB6 forum :D
So, here things are even easier, no need for bitblt, just use 2 bitmaps and set white as the transparent color for one of them (the object bitmap in this case, not the one with the person).
VB Code:
Private Sub GenerateImage()
Dim g As Graphics
Dim b1 As Bitmap
Dim b2 As Bitmap
b1 = New Bitmap("C:\bmpPerson.bmp")
b2 = New Bitmap("C:\bmpObject.bmp") 'White background
b2.MakeTransparent(Color.White)
g = Graphics.FromImage(b1)
g.DrawImage(b2, 0, 0)
PictureBox1.Image = b1 'Add to picturebox1
g.Dispose() 'Bye graphics object
End Sub
Re: Pictures on top of pictures
Correct me if I'm wrong, but with this method, wouldn't any white color be set to transparent, even if it's not in the background???
what if you use background-transparent PNG file format?
1 Attachment(s)
Re: Pictures on top of pictures
Quote:
Originally Posted by jcavard
Correct me if I'm wrong, but with this method, wouldn't any white color be set to transparent, even if it's not in the background???
Yes, that's why masks are not usually created with common colors, magenta is one of the most used.
I attached an example of the code in my previous post.
Re: Pictures on top of pictures
I can't get that code to work for me. Is there another way I could do it?
Re: Pictures on top of pictures
Upload your project (a small version), zipped. Else, it would be hard to guess why it's not working for you.
Re: Pictures on top of pictures
I just can't get the attachment you sent me to work
Re: Pictures on top of pictures
When you press the button, don't you see a Tiger with a red cross in the head?
What version of VS are you using? 2001/2003/2005?
Re: Pictures on top of pictures
Im using VB.NET 2003. The line b2.MakeTransparent(Color.White) comes up as an error. I see the pictures that you sent with you attachment, the tiger and the cross, but i can't get them to work.
Re: Pictures on top of pictures
I'm also using VB.NET 2003, and it's working fine here, so it's weird.
Maybe someone else would have an idea.
Re: Pictures on top of pictures
lol yeah thanks a lot anyway.
Im just starting with vb.net (obvoiusly) and so I'm probably just taking your attachment and doing it wrong.
anyway thanks
Re: Pictures on top of pictures
I have finally been able to make the white in hte pictures disappear, but then it becomes the beigy color of the form itself. So really its the same problem over again. Before the white from the picture in front blocked some of the picture in back, but now I have the white gone, but now the beige from the picture in front, blocks some of the picture in back. It's really the same problem, yes I got ride of the white, but it didn't solve anything.