Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

How to make a GIF inside a picturebox transparent

piscispiscis Posts: 37Member
How to make a GIF inside a picturebox transparent

Does anyone knows how to make an animated GIF inside a picturebox transparent, so the background of the form can be seen?

Thanks

Andy

Comments

  • silverhazesilverhaze Posts: 1Member
    I would like to know the same thing!! someone please reply
  • piscispiscis Posts: 37Member
    : I would like to know the same thing!! someone please reply
    :

    silverhaze:

    After many unsuccessful attempts this is how I did it and it is working like a charm. I have 8 animations running at the same time in the same form.

    First test that the GIF animation does not have a transparent background by dropping a picturebox into VB.NET form and selecting a GIF for the image property, then select property: BACKCOLOR / WEB / TRANSPARENT, the GIF animation will start playing in the designer and you could see immediately if its background is transparent or not.

    If it is not these are the EASY steps to make it transparent:

    1. Download a free 60 days demo copy of Paint Shop Pro 8 (it comes with Animation Shop 3)
    2. Start the programs and select; File > Jasc Software > Launch Animation Shop
    3. Open the GIF in Animation Shop and select; Edit > Select All > Copy
    4. Move to Paint Shop Pro 8 and select; Edit > Paste > As Animation As Multiple Images
    5. Pick any of the images and click on icon named GIF Optimizer on opened window click on Use Wizard > Use Matching Color To Transparent > choose the color if the background and select the defaults provided until the wizard is finished.
    6. Do the same with all the rest of the images.
    7. Go back to Animation Shop and click on Animation Wizard
    8. Accept all the defaults provided until the wizard is finished
    9. Saved your new transparent GIF animation to the Bin folder of your VB.NET solution

    Write the code below and voila!!!

    Hope this help. Let me know

    Andy


    Private pbWaterDropsFast As New PictureBox
    Private WaterDropsFast As Bitmap


    WaterDropsFast = New Bitmap("WaterDropsTransparent.gif")
    With pbWaterDropsFast
    .SizeMode = PictureBoxSizeMode.AutoSize
    .Location = New Point(724, 96)
    .Image = WaterDropsFast
    .BackColor = System.Drawing.Color.Transparent
    End With
    Me.Controls.Add(pbWaterDropsFast)



  • ChazspazChazspaz Posts: 14Member
    picis mate how do u do it with a bmp???
    :
    :
    :
    :

  • EagleEyesEagleEyes Posts: 13Member
    : picis mate how do u do it with a bmp???

    Oh, there's an easier way than downloading that software and going through all those steps. I've done it a few months ago. It will work with GIF and BMP, I tested it on both.

    There is a selection somewhere to make a certain color the transparent color. When you put the picture on your form, look through the things it lets you modify. I forget which it was, but I could tell the program to make a certain color transparent. You DO need to know the exact color, in RGB. For example, blue is (0,0,255) and green is (0,255,0).
    When you make the GIF or BMP in your paint program, make the background or whatever part of the picture you want to be transparent exactly this color. Any other shade, no matter how close it is to this color, will not be transparent.
    This is great for drawing things that require layers. In my game, I have tiles for the ground, and on top of that I have tiles with partial transparency like trees, rocks, animated characters etc.

    If you continue having trouble with this, repost. I'll see if I can dig up the exact code I used to make the transparency.

    -John.
  • ChazspazChazspaz Posts: 14Member
    eagle i still having trouble with my space invaders game. All that happens is the backgroundcolour dissapears. Do u have to print the picture to the form??? if not plz come up with some code because that would be



    chazspaz
Sign In or Register to comment.