<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Hopes

    Start Here..

     

    C# GDI+與圖形編程

    C# GDI+與圖形編程

    2011-11-08 13:12 by Mr.Xer, 432 閱讀, 1 評論, 收藏編輯

    GDI+與圖形編程

    GDI+的基本概念

    GDI+的常用對象,包括Graphics、Font、Brush、Pen等對象的創(chuàng)建和使用

    常用圖形的繪制

    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創(chuàng)建Graphics對象。

    (2)使用窗體或控件的CreateGraphics方法

           Graphics  g=this.CreateGraphics();

    (3)使用Image的派生類創(chuàng)建Graphics對象。使用Image的任何派生類均可以生成相應的Graphics對象,這種方法一般適用于在C#中對圖像進行處理的場合。

                  Bitmap b=new Bitmap("Mybmp.bmp");

    Graphics g=Graphics.FromImage(b);

     

    Pen對象

    Pen類的構造函數有四種,使用方法如下。

    (1)創(chuàng)建某一顏色的Pen對象:public Pen(Color)

    (2)創(chuàng)建某一刷子樣式的Pen對象:public Pen(Brush)

    (3)創(chuàng)建某—刷子樣式并具有相應寬度的Pen對象:public Pen(Brush,float)

    (4)創(chuàng)建某一顏色和相應寬度的Pen對象:public Pen(Color,float)

    Pen對象的常用屬性

    (1)Alignment屬性:用來獲取或設置此Pen對象的對齊方式。

    (2)Color屬性:用來獲取或設置此Pen對象的顏色。

    (3)Width屬性:用來獲取或設置此Pen對象的寬度。

    (4)DashStyle屬性:用來獲取或設置通過此Pen對象繪制的虛線的樣式。

    (5)DashCap屬性:用來指定虛線兩端風格,是一個DashCap枚舉型的值。

    (6)StartCap屬性:用來獲取或設置通過此Pen對象繪制的直線起點的帽樣式。

    (7)EndCap屬性:用來獲取或設置通過此Pen對象繪制的直線終點的帽樣式。

    (8)PenType屬性:用來獲取用此Pen對象繪制的直線的樣式。 

     

     

    Font對象


     

     

    Brush對象

    1.SolidBrush畫刷

       SolidBrush類用來定義單一顏色的Brush,其構造函數如下。

       public SolidBrush(Color.Color)

    2.HatchBrush畫刷

          HatchBrush類的構造函數有兩種,分別如下:  

    [格式1]:public HatchBrush(HatchStyle, Color);

    [格式2]:public HatchBrush(HatchStyle, Color, Color); HatchBrush畫刷具有三個屬性,分別如下:

    (1)BackgroundColor屬性:獲取此HatchBrush 對象的背景色。

    (2)ForegroundColor屬性:獲取此HatchBrush 對象的前景色。

    (3)HatchStyle屬性:獲取此HatchBrush 對象的陰影樣式。

    3.LinearGradientBrush畫刷

    LinearGradientBrush類的構造函數有多種格式,最常用的格式如下。

        public LinearGradientBrush(Point1, Point2, Color1, Color2);

     

     

    常用圖形的繪制方法

    1.畫直線

          [格式1]:public void DrawLine(Pen pen,int x1,int y1,int x2,int y2);

          [格式2]:public void DrawLine(Pen pen,Point pt1,Point pt2);

    2.畫橢圓

    [格式1]:public void DrawEllipse( Pen pen, Rectangle rect);

    [格式2]:public void DrawEllipse(Pen pen,int x,int y,int width, int height);

    3.繪制圓弧

    [格式1]:public void DrawArc(Pen pen,Rectangle rect,float startAngle,float sweepAngle);

    [格式2]:public void DrawArc(Pen pen,int x,int y,int width,int height,int startAngle,int sweepAngle);

    4.畫扇形圖

    使用Graphics對象的DrawPie方法可以繪制扇形圖,所謂扇形圖其實就是把一段圓弧的兩個端點與圓心相連。DrawPie方法的格式與DrawArc方法基本一致。

    5.畫矩形

    [格式1]: public void DrawRectangle( Pen pen, Rectangle rect);

    [格式2]:public void DrawRectangle(Pen pen,int x,int y,int width,int height);

    6.畫Bezier曲線

    [格式1]:public void DrawBezier(Pen pen,Point pt1,Point pt2,Point pt3,Point pt4);

    [格式2]:public void DrawBezier(Pen pen,float x1,float y1,float x2,float y2,float x3,float y3,float x4,float y4);

    7.畫多邊形

    [格式1]:public void DrawPolygon(Pen pen,  Point[] points);

    [格式2]:public void DrawPolygon(Pen pen, PointF[] points);

    8.繪制閉合曲線

    [格式1]:public void DrawClosedCurve(Pen pen,Point[] points);

    [格式2]:public void DrawClosedCurve(Pen pen,Point[] points,float tension,FillMode fillmode);

    9.繪制非閉合曲線

    [格式]:public void DrawCurve( Pen pen,Point[] points);

    10.繪制路徑

    [格式]:public void DrawPath(Pen pen,GraphicsPath path);

    11.填充橢圓

    [格式1]:public void FillEllipse(Brush brush, Rectangle rect);

    [格式2]:public void DrawEllipse(Brush brush,int x,int y,int width, int height);

    12.填充矩形

    [格式1]: public void FillRectangle( Brush brush, Rectangle rect);

    [格式2]:public void FillRectangle(Brush brush,int x,int y,int width,int height);

    13.填充餅圖

    [格式1]:public void FillPie(Brush brush,Rectangle rect,float startAngle,float sweepAngle)

    [格式2]:public void FillPie(Brush brush,int x,int y,int width,int height,int startAngle,int sweepAngle);

    分類: C#

    posted on 2012-08-19 14:36 ** 閱讀(502) 評論(0)  編輯  收藏


    只有注冊用戶登錄后才能發(fā)表評論。


    網站導航:
     

    導航

    統計

    公告

    你好!

    常用鏈接

    留言簿(2)

    隨筆檔案

    文章分類

    文章檔案

    新聞檔案

    相冊

    收藏夾

    C#學習

    友情鏈接

    搜索

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 香蕉国产在线观看免费| 亚洲精品线在线观看| 精品日韩99亚洲的在线发布| 日韩电影免费在线观看中文字幕| 亚洲高清免费视频| 污网站在线观看免费| 亚洲Av永久无码精品三区在线| free哆拍拍免费永久视频| 国产成人免费A在线视频| 4虎1515hh永久免费| 中文字幕 亚洲 有码 在线| 精品亚洲麻豆1区2区3区| 亚洲国产美国国产综合一区二区 | 男女男精品网站免费观看| 免费成人av电影| 国产高清对白在线观看免费91| 亚洲中久无码不卡永久在线观看| 亚洲日韩中文字幕| 成人黄网站片免费视频| 国产极品粉嫩泬免费观看| 特黄特色大片免费| 久久精品国产精品亚洲精品| 亚洲AV一二三区成人影片| 99re热免费精品视频观看| 亚洲日韩在线中文字幕综合| 日韩免费电影网站| 亚洲爱情岛论坛永久| 国产免费人成视频尤勿视频 | 亚洲欧洲日产国码av系列天堂| 综合自拍亚洲综合图不卡区| 免费播放美女一级毛片| 在线免费观看一区二区三区| 国产成人精品男人免费| 91av免费在线视频| 久久精品国产亚洲av麻豆蜜芽 | 亚洲精选在线观看| 最近免费中文字幕视频高清在线看| 亚洲日本精品一区二区| 永久黄网站色视频免费| 野花香在线视频免费观看大全 | 香港a毛片免费观看 |