本帖最后由 s000rd 于 2012-02-24 15:08:41 编辑

解决方案 »

  1.   

    为啥不一样不知道,要不你用 LinearGradientBrush
     试试渐变色?
      

  2.   

    LinearGradientBrush好像无法填充圆形
      

  3.   

    protected void Page_Load(object sender, EventArgs e)
            {
                Bitmap bmp = new Bitmap(200, 200);
                Graphics g = Graphics.FromImage(bmp);
                Color cStart = Color.FromArgb(40, 0, 0, 0);
                Color cEnd = Color.FromArgb(255, 0, 0, 255);
                int radius = 100;
                GraphicsPath path = new GraphicsPath();
                path.AddEllipse(0, 0, radius * 2, radius * 2);
                PathGradientBrush pthGrBrush = new PathGradientBrush(path);
                pthGrBrush.CenterColor = cEnd;
                Color[] colors = { cStart };
                pthGrBrush.SurroundColors = colors;
                g.FillEllipse(pthGrBrush, 0, 0, radius * 2, radius * 2);
                bmp.Save("d:\\1.png");
                bmp.Dispose();
                g.Dispose();        }
      

  4.   

    或者path渐变是否能实现多种颜色的渐变?比如中心红色,中间位黄色,边上为蓝色?调试半天没有效果
      

  5.   

    Color cStart = Color.FromArgb(40, 0, 0, 0); //alpha是否要为0?pthGrBrush.InterpolationColors = new ColorBlend(3)
    {
        Colors = new[] { Color.Blue, Color.Yellow, Color.Red },
        Positions = new[] { 0f, .5f, 1f },
    };
      

  6.   

    Gradients made easy
      

  7.   

    我现在实现了就是这种效果,但看了下html5中的效果,貌似是在这个基础上,有中心向两边透明渐变。但在gdi+中,如果第二种渐变色为透明,则显示的效果如上图,只有一种颜色。