GDIブラシ

一、solidBrush

ソリッドカラーの塗りつぶし

ペイントイベントの形式を使用します

        プライベート 無効 Form1_Paint(オブジェクト送信者、PaintEventArgsのe)の
        {
            グラフィックG = e.Graphics。
            ブラシBR = 新しいSolidBrush(Color.Red)。
            g.FillRectangle(BR、1010100100 )。
            g.Dispose();
         }
Form1_Paint

二、たTextureBrush

ビットマップの塗りを使用して

最初の画像を追加

 

使用してSystem.IOを。
        プライベート 無効 Form1_Paint(オブジェクト送信者、PaintEventArgsのe)の
        {
            文字列のパス= @ " F:\ Lianxi \ App1の\ App1の\ IMG \となりのトトロ.JPG " 
            グラフィックG = e.Graphics。

            ビットマップIMG;
            もし(File.Exists(パス))
            {
                IMG = 新しいビットマップ(パス)。
                ブラシBRは = 新しいたTextureBrush(IMG)。
                g.FillRectangle(BR、3030500400 )。
            }
            
            {
                MessageBox.Show(あなたが記入したい画像を見つけることができませんヒント、MessageBoxButtons.OK)。  
            }

            g.Dispose(); // グラフィックスで使用されるリリースリソース 
         }
Form1_Paint

 

 三、LinearGradientBrush

直線勾配

使用してSystem.Drawing.Drawing2Dを。
        プライベート 無効 Form1_Paint(オブジェクト送信者、PaintEventArgsのe)の
        {
            グラフィックG = e.Graphics。
            LinearGradientBrush LGB = 新しい LinearGradientBrush(新しい点(0140)、新しいポイント(280140 )、Color.Red、Color.White)。
            g.FillEllipse(LGB、0140280120 )。
            lgb.Dispose();
            g.Dispose();
        }
Form1_Paint

 

四、PathGradientBrush 

グラデーションの中心点

使用してSystem.Drawing.Drawing2Dを。
        プライベート 無効 Form1_Paint(オブジェクト送信者、PaintEventArgsのe)の
        {
            GraphicsPath GP = 新しいGraphicsPath();
            gp.AddEllipse(080280120 )。
            PathGradientBrush PGB = 新しいPathGradientBrush(GP);
            pgb.CenterColor = Color.FromArgb(025525520 )。
            色[]色 = {Color.FromArgb(25502550)}。// FromArgb(透明度、R、G、B) 
            pgb.SurroundColors = 色。
            e.Graphics.FillEllipse(PGB、080280120 )。
            pgb.Dispose();
        }
Form1_Paint

 

五、HatchBrush

細長いテーブルを埋めるために

 

 

使用してSystem.Drawing.Drawing2Dを。
       プライベート 無効 Form1_Paint(オブジェクト送信者、PaintEventArgsのe)の
        {
            HatchBrush hatchBrush = 新しいHatchBrush(HatchStyle.Horizo​​ntalBrick、Color.White、Color.Red)。
            e.Graphics.FillRectangle(hatchBrush、1010100100 )。
            e.Graphics.Dispose();
        }
Form1_Paint

 

おすすめ

転載: www.cnblogs.com/Luck1996/p/11976802.html