没有合适的资源?快使用搜索试试~ 我知道了~
首页C#中Graphics各种方法的用法详解
C#中Graphics各种方法的用法详解

C#中Graphics各种方法的用法详解,graphics方法-属性,画笔对象,绘制各种图形,作为技术文档,方便查找,欢迎下载
资源详情
资源评论
资源推荐

C# graphics 方法
C#2010-05-07 09:30:57 阅读 467 评论 0 字号:大中小 订阅
命名空间:System.Drawing
程序集:System.Drawing(在 system.drawing.dll 中)
封装一个 GDI+ 绘图图面。无法继承此类。
C# 用法
public sealed class Graphics : MarshalByRefObject, IDeviceContext,
IDisposable
System.Drawing.Pen myPen = new
System.Drawing.Pen(System.Drawing.Color.Red);//画笔
System.Drawing.SolidBrush myBrush = new
System.Drawing.SolidBrush(System.Drawing.Color.Red);//画刷
System.Drawing.Graphics formGraphics = this.CreateGraphics();
formGraphics.FillEllipse(myBrush, new Rectangle(0,0,100,200));//画实心
椭圆
formGraphics.DrawEllipse(myPen, new Rectangle(0,0,100,200));//空心圆
formGraphics.FillRectangle(myBrush, new Rectangle(0,0,100,200));//画实
心方
formGraphics.DrawRectangle(myPen, new Rectangle(0,0,100,200));//空心矩
形
formGraphics.DrawLine(myPen, 0, 0, 200, 200);//画线
formGraphics.DrawPie(myPen,90,80,140,40,120,100); //画馅饼图形 //画多
边形
formGraphics.DrawPolygon(myPen,new Point[]{ new Point(30,140), new
Point(270,250), new Point(110,240), new Point (200,170), new
Point(70,350), new Point(50,200)}); //清理使用的资源
myPen.Dispose();
myBrush.Dispose();

formGraphics.Dispose();
使用 Graphics 对象绘制线条和形状、呈现文本或显示与操作图像,所用到的属
性和方法如表所示。
graphics 方法-属性
名称
说明
Clip 获取或设置 Region,该对象限定此 Graphics 的绘图区域。
ClipBounds 获取一个 RectangleF 结构,该结构限定此 Graphics 的剪辑区域。
CompositingMode 获取一个值,该值指定如何将合成图像绘制到此 Graphics。
CompositingQuality
获取或设置绘制到此 Graphics 的合成图像的呈现质量。
DpiX 获取此 Graphics 的水平分辨率。
DpiY 获取此 Graphics 的垂直分辨率。
InterpolationMode 获取或设置与此 Graphics 关联的插补模式。
IsClipEmpty 获取一个值,该值指示此 Graphics 的剪辑区域是否为空。
IsVisibleClipEmpty 获取一个值,该值指示此 Graphics 的可见剪辑区域是否
为空。
PageScale 获取或设置此 Graphics 的全局单位和页单位之间的比例。
PageUnit 获取或设置用于此 Graphics 中的页坐标的度量单位。

PixelOffsetMode 获取或设置一个值,该值指定在呈现此 Graphics 的过程中像
素如何偏移。
RenderingOrigin 为抵色处理和阴影画笔获取或设置此 Graphics 的呈现原点。
SmoothingMode 获取或设置此 Graphics 的呈现质量。
TextContrast 获取或设置呈现文本的灰度校正值。
TextRenderingHint 获取或设置与此 Graphics 关联的文本的呈现模式。
Transform
获取或设置此 Graphics 的世界变换。
VisibleClipBounds 获取此 Graphics 的可见剪辑区域的边框。
graphics 方法-方法
名称
说明
AddMetafileComment
向当前 Metafile 添加注释。
BeginContainer
保存具有此 Graphics 的当前状态的图形容器,然后打开并使用新的图形容器。
可重载。
Clear
清除整个绘图面并以指定背景色填充。
剩余10页未读,继续阅读











安全验证
文档复制为VIP权益,开通VIP直接复制

评论2