GDI+的基本概念
GDI+的常用對象,包括Graphics、Font、Brush、Pen等對象的創建和使用
常用圖形的繪制
Color結構、Point結構和Rectangle結構
1.GDI+的概念
GDI+是GDI(Graphics Device Interface,圖形設備接口)的改進產品。
2.GDI+的繪圖命名空間
用戶所使有的GDI+函數都保存在System.Drawing.d11程序集中。其中包括System.Drawing、System.Drawing.Text、System.Drawing.PRinting、System.Drawing.Imaging、System.Drawing.Drawing2D和System.Drawing.Design等命名空間。
Graphics對象
(1)利用窗體或控件的Paint事件的參數PaintEventArgs創建Graphics對象。
(2)使用窗體或控件的CreateGraphics方法
Graphicsg=this.CreateGraphics();
(3)使用Image的派生類創建Graphics對象。使用Image的任何派生類均可以生成相應的Graphics對象,這種方法一般適用于在C#中對圖像進行處理的場合。
Bitmap b=new Bitmap("Mybmp.bmp");
Graphics g=Graphics.FromImage(b);
Pen對象
Pen類的構造函數有四種,使用方法如下。
(1)創建某一顏色的Pen對象:public Pen(Color)
(2)創建某一刷子樣式的Pen對象:public Pen(Brush)
(3)創建某—刷子樣式并具有相應寬度的Pen對象:public Pen(Brush,float)
(4)創建某一顏色和相應寬度的Pen對象:public Pen(Color,float)
Word-spacing: 0px; white-space: normal; font-size-adjust: none; font-stretch: normal; background-color: #ffffff; -w
新聞熱點
疑難解答