首页 > 学院 > 开发设计 > 正文

GDI+与图形编程研究

2019-11-17 02:59:39
字体:
来源:转载
供稿:网友
GDI+与图形编程研究

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

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表