<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#學習

    友情鏈接

    搜索

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 又大又硬又爽又粗又快的视频免费| 亚洲精品国产综合久久一线| 青青青国产在线观看免费网站| 我的小后妈韩剧在线看免费高清版| 女人让男人免费桶爽30分钟| 亚洲精品A在线观看| 亚洲视频中文字幕| 免费A级毛片在线播放| 成年轻人网站色免费看| 国产亚洲A∨片在线观看| 亚洲欧洲日韩极速播放| aa在线免费观看| 亚洲精品美女久久777777| 亚洲AV一二三区成人影片| 成人av片无码免费天天看| 成人免费视频77777| ZZIJZZIJ亚洲日本少妇JIZJIZ| 亚洲视频小说图片| 国产啪精品视频网免费| 久久亚洲中文字幕精品一区四 | 亚洲欧洲日产专区| av无码国产在线看免费网站| 国产亚洲美日韩AV中文字幕无码成人| 国产黄色片免费看| 亚洲人成网www| 最近免费中文字幕视频高清在线看 | 国产成人无码免费看片软件| 免费A级毛片无码无遮挡内射| 中文字幕第13亚洲另类| 亚洲hairy多毛pics大全| 99久热只有精品视频免费看 | mm1313亚洲国产精品美女| 亚洲三级在线播放| 国产18禁黄网站免费观看| 亚洲国产精品成人综合久久久 | 久久久久国色av免费看 | 亚洲精品乱码久久久久久下载| 国产免费人成视频在线播放播 | 亚洲午夜久久久影院伊人| 国产亚洲高清在线精品不卡| 免费专区丝袜脚调教视频|