畫一個漸變的影像

weixin_30639719發表於2020-04-05

轉自: http://dev.mjxy.cn/a-169.aspx

using System;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Drawing2D;

namespace DevDistrict.Sample
{
        public class GradientPanel : System.Windows.Forms.Panel
        {
                protected override void OnPaint(PaintEventArgs e)
                {
                        base.OnPaint (e);

                        Graphics g = e.Graphics;

                        g.SmoothingMode = SmoothingMode.HighQuality;
                        GraphicsPath gPath = new GraphicsPath();

                        Rectangle r = new Rectangle(0,0,this.Width,this.Height);
                        gPath.AddRectangle(r);

                        LinearGradientBrush lb = new LinearGradientBrush(r,Color.White,Color.Blue,LinearGradientMode.Vertical);

                        g.FillPath(lb,gPath);
                }
        }
}

轉載於:https://www.cnblogs.com/xingquan/archive/2011/07/08/2101050.html

相關文章