| re: How to draw a transparent gif in web
You have to explicity set transparent color.
See Bitmap.MakeTransparent
It might help.
George.
"Minhua Fu" <minhua.fu@sympatico.ca> wrote in message
news:ybiIb.5181$Vl6.1369624@news20.bellglobal.com. ..[color=blue]
> Hi,
>
> I have a problem when I draw a transparent gif picture. I have an existing
> transparent gif picture, i want to modify the gif and save it to
> reponse.outstream. But the picture always keep black backgroup. Can anyone
> give me some suggestions?
>
> Following is my code.
>
> System.Drawing.Image img =
> System.Drawing.Image.FromFile(Server.MapPath("imag es\\menubutton.gif"));
>
> bmWidth = img.Width;
>
> bmHeight = img.Height;
>
> Bitmap bm = new Bitmap(bmWidth, bmHeight);
>
>
> Graphics g = Graphics.FromImage(bm);
>
>
> stringSize = g.MeasureString(menuname, menuFont);
>
>
> g.DrawImage(img, 0, 0);
>
> g.DrawString(menuname, menuFont, new SolidBrush(Color.Black),
>
> (bmWidth - stringSize.Width) / 2, (bmHeight - stringSize.Height) / 2);
>
>
> Response.ContentType="image/gif";
>
> bm.Save(Response.OutputStream, ImageFormat.Gif);
>
>
>
> Thanks
>
> Mike
>
>[/color] |