Bitmap b = new Bitmap(600,600);
Graphics g = Graphics.FromImage(b);//GDI+中最重要的类
g.Clear(Color.Red);
Pen p = new Pen(Color.Green,3.0f);//铅笔
g.DrawLine(p,0,0,600,600);
g.DrawLine(p,600,0,0,600);
g.DrawEllipse(p,0,0,100,100);
SolidBrush sb = new SolidBrush(Color.Blue);//固体刷
g.FillEllipse(sb,100,100,200,200);
g.FillRectangle(sb,300,300,100,100);
Font f = new Font("宋体",40);//字体
g.DrawString("哈哈,不错!",f,sb,0,300);
Point[] arrP = new Point[5];//point为基本的点
arrP[0] = new Point(200,200);
arrP[1] = new Point(200,400);
arrP[2] = new Point(500,400);
arrP[3] = new Point(500,600);
arrP[4] = new Point(300,600);
g.DrawPolygon(p,arrP);
b.Save(Response.OutputStream,ImageFormat.Gif);
Graphics g = Graphics.FromImage(b);//GDI+中最重要的类
g.Clear(Color.Red);
Pen p = new Pen(Color.Green,3.0f);//铅笔
g.DrawLine(p,0,0,600,600);
g.DrawLine(p,600,0,0,600);
g.DrawEllipse(p,0,0,100,100);
SolidBrush sb = new SolidBrush(Color.Blue);//固体刷
g.FillEllipse(sb,100,100,200,200);
g.FillRectangle(sb,300,300,100,100);
Font f = new Font("宋体",40);//字体
g.DrawString("哈哈,不错!",f,sb,0,300);
Point[] arrP = new Point[5];//point为基本的点
arrP[0] = new Point(200,200);
arrP[1] = new Point(200,400);
arrP[2] = new Point(500,400);
arrP[3] = new Point(500,600);
arrP[4] = new Point(300,600);
g.DrawPolygon(p,arrP);
b.Save(Response.OutputStream,ImageFormat.Gif);
本文通过一个具体的示例介绍了如何使用GDI+进行基本的绘图操作,包括画线、画椭圆、填充颜色及绘制文本等,并展示了如何创建和使用Pen和SolidBrush对象。

1309

被折叠的 条评论
为什么被折叠?



