使默认的透明颜色对此 Bitmap 透明。
[C#]
public void MakeTransparent_Example(PaintEventArgs e){// Create a Bitmap object from an image file.Bitmap myBitmap = new Bitmap("Grapes.gif");// Draw myBitmap to the screen.e.Graphics.DrawImage(myBitmap,0,0,myBitmap.Width,myBitmap.Height);// Get the color of a background pixel.Color backColor = myBitmap.GetPixel(1, 1);// Make backColor transparent for myBitmap.myBitmap.MakeTransparent(backColor);// Draw the transparent bitmap to the screen.e.Graphics.DrawImage(myBitmap,myBitmap.Width,0,myBitmap.Width,myBitmap.Height);}
[C#]
public void MakeTransparent_Example(PaintEventArgs e){// Create a Bitmap object from an image file.Bitmap myBitmap = new Bitmap("Grapes.gif");// Draw myBitmap to the screen.e.Graphics.DrawImage(myBitmap,0,0,myBitmap.Width,myBitmap.Height);// Get the color of a background pixel.Color backColor = myBitmap.GetPixel(1, 1);// Make backColor transparent for myBitmap.myBitmap.MakeTransparent(backColor);// Draw the transparent bitmap to the screen.e.Graphics.DrawImage(myBitmap,myBitmap.Width,0,myBitmap.Width,myBitmap.Height);}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货