Results 1 to 12 of 12

Thread: [RESOLVED] Pictures on top of pictures

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    40

    Resolved [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

  2. #2
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: Pictures on top of pictures

    Sorry, I deleted my post, I thought this thread was in the VB6 forum
    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:
    1. Private Sub GenerateImage()
    2.         Dim g As Graphics
    3.         Dim b1 As Bitmap
    4.         Dim b2 As Bitmap
    5.  
    6.         b1 = New Bitmap("C:\bmpPerson.bmp")
    7.         b2 = New Bitmap("C:\bmpObject.bmp") 'White background
    8.         b2.MakeTransparent(Color.White)
    9.         g = Graphics.FromImage(b1)
    10.  
    11.         g.DrawImage(b2, 0, 0)
    12.         PictureBox1.Image = b1 'Add to picturebox1
    13.         g.Dispose() 'Bye graphics object
    14.     End Sub
    Last edited by jcis; Mar 10th, 2006 at 02:35 PM.

  3. #3
    Fanatic Member jcavard's Avatar
    Join Date
    Jul 2005
    Location
    Quebec, CANADA
    Posts
    534

    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?
    Last edited by jcavard; Mar 10th, 2006 at 02:39 PM. Reason: questionning
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

    accoustic emo-rock band: a tailormade fable

    Visual Studio 2003 / Framework 1.1

  4. #4
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    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.
    Attached Files Attached Files

  5. #5

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    40

    Re: Pictures on top of pictures

    I can't get that code to work for me. Is there another way I could do it?

  6. #6
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    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.

  7. #7

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    40

    Re: Pictures on top of pictures

    I just can't get the attachment you sent me to work

  8. #8
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    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?

  9. #9

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    40

    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.

  10. #10
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    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.

  11. #11

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    40

    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

  12. #12

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    40

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width