How to make a color transparent? - need help

  • Thread starter Thread starter Josch
  • Start date Start date
J

Josch

I have here a specific problem with ASP.NET in C#. I want to convert an Icon
(System.Drawing.Icon icon) to a GIF-Image.

First, my attempt was converting the icon to a Bitmap:

Bitmap bmp = icon.ToBitmap();

Then save this Bitmap as a GIF-Image:

bmp.Save("mypic.gif",ImageFormat.Gif);

OK, this works but when I load the new GIF-Image into my Browser, the
defined transparent color is black.

My second attempt was to define the color in the Bitmap manually as
transparent.

Bitmap bmp = icon.ToBitmap();
bmp.MakeTransparent(bmp.GetPixel(0,0));
bmp.Save("mypic.gif",ImageFormat.Gif);

So I was in big hope, but this also doesn't work. Has anybody an idea, how i
can manage this?

Thanks a lot!!
 
Back
Top