C_GDI+编程教程(11)

时间:2025-04-20

本章主要介绍使用C#进行图形图像编程基础,其中包括GDI+绘图基础、C#图像处理基础以及简单的图像处理技术。

注意:GraphicsPath类位于命名空间System.Drawing.Drawing2D中,表示一系列相互连接的直线和曲线。

7.1.5 画刷和画刷类型

Brush类型是一个抽象类,所以它不能被实例化,也就是不能直接应用,但是我们可以利用它的派生类,如:HatchBrush、SolidBrush和TextureBrush等。画刷类型一般在System.Drawing命名空间中,如果应用HatchBrush和GradientBrush画刷,需要在程序中引入System.Drawing.Drawing2D命名空间。

1.SolidBrush(单色画刷)

它是一种一般的画刷,通常只用一种颜色去填充GDI+图形,例如:

protected override void OnPaint(PaintEventArgs e) {

Graphics g = e.Graphics;

SolidBrush sdBrush1 = new SolidBrush(Color.Red); SolidBrush sdBrush2 = new SolidBrush(Color.Green); SolidBrush sdBrush3 = new SolidBrush(Color.Blue); g.FillEllipse(sdBrush2, 20, 40, 60, 70);

Rectangle rect = new Rectangle(0, 0, 200, 100); g.FillPie(sdBrush3, 0, 0, 200, 40, 0.0f, 30.0f ); PointF point1 = new PointF(50.0f, 250.0f); PointF point2 = new PointF(100.0f, 25.0f); PointF point3 = new PointF(150.0f, 40.0f); PointF point4 = new PointF(250.0f, 50.0f); PointF point5 = new PointF(300.0f, 100.0f);

PointF[] curvePoints = {point1, point2, point3, point4,point5 }; g.FillPolygon(sdBrush1, curvePoints); }

运行结果如图7.7所示。

C_GDI+编程教程(11).doc 将本文的Word文档下载到电脑

精彩图片

热门精选

大家正在看

× 游客快捷下载通道(下载后可以自由复制和排版)

限时特价:7 元/份 原价:20元

支付方式:

开通VIP包月会员 特价:29元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219