画透明的图片

在使用Graphics.DrawImage()时,图片会有背景色,怎么样可以是图片透明,可以使用如下方法:

Image image;

Graphics gx;

Bitmap bmp=new Bitmap(image);

Color color=bmp.GetPixel(0,0);

ImageAttributes imgAttr=new ImageAttributes();

imgAttr.SetColorKey(color,color);

gx.DrawImage(image,rect,0,0,image.Width,image.Height,GraphicsUnit.Pixel,imgAttr);

posted @ 2010-12-07 11:35  古韵古风  阅读(217)  评论(0编辑  收藏  举报