Making image colors transparent

  • Thread starter Thread starter Tony Clark
  • Start date Start date
T

Tony Clark

Hi,

I have a bmp that is set in a panel, i want to make the white color in the
bmp image transparent so i can see the color of the panel below. How is
this done?

thanks
tony
 
You wouldn't. This can't be done with a Bitmap, but only with an icon or a
cursor.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer

Presuming that God is "only an idea" -
Ideas exist.
Therefore, God exists.
 
I don't know if this is what you are after, but I would take the bitmap,
erase the white color, and give it a transparent background (PhotoShop works
nicely for this). Then you can import the new gif into the editor.

Rob K
 
Hey Tony, if you don't mind getting your hands a little dirty with
graphics, try Paint .NET . I've been using it for a couple of weeks now
and I'm pretty happy with it. Took a little while to learn since I had
never used an imaging program before. Now that I know how to do it
though, I'm able to do a fair amount of tweaking of images without
having to send them back to the graphic arts guys I work with.

If you're trying to programmatically add in the transparency, then that
cannot be done. Good luck ~ Justin
 
It doesn't matter, Justin. The image is in a panel. It cannot be rendered
transparent. What he *could* do is override the Paint event that paints the
image, and draw all the white pixels the same color as the BackColor of the
Panel.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer

Presuming that God is "only an idea" -
Ideas exist.
Therefore, God exists.
 
Tony said:
Hi,

I have a bmp that is set in a panel, i want to make the white color in the
bmp image transparent so i can see the color of the panel below. How is
this done?

thanks
tony
This is a bit roundabout but it works for me in .NET 2.0:

1 Add an ImageList to your form.
2 Put your bmp image into your ImageList.
3 Set the image size and transparent colour (white) in your ImageList.
4 Switch to the code view and add the line below to the end of your
form's constructor:

panel1.BackgroundImage = imageList1.Images[0];

(0 is the index of your image in your ImageList)


I had to load the image in code because I could not see a way to point
the
panel background image to the ImageList in the Properties window.

The same method works for a PictureBox as well:
pictureBox1.Image = imageList1.Images[0];

In both cases the colour assigned as transparent in the ImageList was
indeed transparent.

rossum
 
Back
Top