在winfrom中,怎样让病虫防治周边的白边去掉为透明,成为一圆形的图片按钮啊?  (我在photoshop中是四周的白边处理为透明的啊,用picturebox导入的病虫防治这图)
这里有具体的截图:http://space.cnblogs.com/question/11565/

解决方案 »

  1.   

    很简单:我抄一段给你,将传入控件变成圆形的代码给你吧,//...
    public void MakeShapeToRound(Control c){
      GraphicsPath gp=new GraphicsPath();
      gp.AddEllipse(new Rectangle(0,0,c.Size.Width-5,c.Size.Height-5));
      c.Region=new Region(gp);
    }
      

  2.   

    http://www.codeproject.com/KB/buttons/RoundButton_csharp.aspx
      

  3.   

    我写了一个,但是没有结果,晕,我贴出来,大家看下吧
     private void Form1_Paint(object sender, PaintEventArgs e)
            {
                Bitmap bmp = new Bitmap(@"f:\picture\temp.jpg");
                getRegion(bmp);
                this.BackgroundImage = bmp;
            }
            private static Region getRegion(Bitmap bmp)
            {
                GraphicsPath path = new GraphicsPath();
                Color first = bmp.GetPixel(0, 0);
                for (int i = 0; i < bmp.Height; i++)
                {
                    for (int j = 0; j < bmp.Width; j++)
                    {
                        Color second=bmp.GetPixel(j,i);
                        if (second != first)
                        {
                            path.AddRectangle(new Rectangle(i,j,1,1));
                        }
                    }
                }
                Region g = new Region(path);
                return g;
            }