Bitmap.MakeTransparent makes background black

B

BIG_j

I have dynamic image(s) on the clipboard that I need to save as a
transparent gif. There are a number of posts regarding MakeTransparent but I
cannot get this to work for what I am trying to do. I am NOT loading the
picture into a form and there are no paint events to consider.

I am simply loading the image from the clipboard and saving it to a file.
Anyone have a solution or workaround??


Here is the code snippet...


Bitmap Img = new Bitmap((Bitmap)Data.GetData(DataFormats.Bitmap, true));

//makes bg black
//Img.MakeTransparent(System.Drawing.Color.FromArgb(255,255,255));

//makes bg black, even though 1,1 is white
//Img.MakeTransparent(Img.GetPixel(1,1));

//makes bg black
//Img.MakeTransparent();

Img.Save("C:\\testImage.gif", System.Drawing.Imaging.ImageFormat.Gif);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top