-1

I'm trying to find a solution how to make an image's background transparent. I'm programming a small and easy 2D game with a scrolling background that displays a sky. You'll see the code if you follow the link: Avoiding creating PictureBoxes again and again

    picBoxImage = new PictureBox();
    picBoxImage.Image = new Bitmap("Path");
    picBoxImage.SetBounds(100, 100, 100, 100);
    this.Controls.Add(picBoxImage);

The code above shows the inclusion of the image to the Windows Form. Now the object (let's say the image does show an aircraft) has been set over the other images showing the sky.

How is it possible to set the background of the aircraft's image transparent? It is important that the aircraft is seen without any perturbing white background.

Would you mind giving me some code to solve the problem?

Community
  • 1
  • 1
  • 1
    That's not an image, that's a picture box. A `Control` to render an image... – Willem Van Onsem Feb 20 '15 at 00:44
  • What is the background of the aircraft you want to make transparent? – Willem Van Onsem Feb 20 '15 at 00:46
  • Usually if you save an image then the problem is that the white background is stored as well. I was trying to remove the white background with gimp but it still remains. – Lucky Buggy Feb 20 '15 at 00:58
  • There are couple exiting answers (I used one as duplicate) about rendering transparent images. Feel free to use following search http://www.bing.com/search?q=c%23+draw+transparent+image to find more. If you clarify&edit you question so it is clear that is no longer duplicate of generic "render transparent image" - make sure to add comment to you post with `@Alex` so I get notified and can remove duplicate vote. – Alexei Levenkov Feb 20 '15 at 01:09
  • Bitmap bitmap = new Bitmap("Path"); picBoxImage = new PictureBox(); picBoxImage.Image = bitmap; picBoxImage.SetBounds(100, 100, 125, 50); bitmap.MakeTransparent(Color.Red); this.Controls.Add(picBoxImage); – Lucky Buggy Feb 20 '15 at 19:59

1 Answers1

0

I don't know if you're talking about what kind of image file or maybe the css that gives you that "effect".

I think you're talking about the image file. In that case, .png files let you to set transparent background.

If it wasn't what you are looking for,...sorry.

cooper
  • 635
  • 1
  • 8
  • 23