分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow
也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!
学习贴图,可拉伸图片大小
学习使用画刷,创建不同类型画刷,并用画刷产生画笔
- private void button1_Click(object sender, EventArgs e)//画图响应按钮(类似完成MFC中BitBlt或StrechBlt的功能)
- {
- Bitmap bitmap = new Bitmap(@"D:/工作照.jpg");
- Graphics g = CreateGraphics();
- //获得窗口屏幕大小
- Rectangle rect = System.Windows.Forms.SystemInformation.VirtualScreen;
- int width = rect.Width;
- int height = rect.Height;
- g.DrawImage(bitmap, rect);
- button1.Visible = true;
- }
- private void button2_Click(object sender, EventArgs e)//动态输出文字(类似MFC中的TextOut())
- {
- Font myFont = new Font("Verdana", 12);
- Graphics g = CreateGraphics();
- //创建线渐变画刷:
- LinearGradientBrush myBrush = new LinearGradientBrush(ClientRectangle, Color.FromArgb(120, 120, 250), Color.Red, LinearGradientMode.Vertical);
- // g.DrawString("GDI 显示字符串", myFont, myBrush, new RectangleF(10, 10, 500, 200));
- //创建一般画刷:
- SolidBrush bru1 = new SolidBrush(Color.FromArgb(250, 200, 0));
- g.DrawString("GDI 显示字符串", myFont, bru1, new RectangleF(10, 10, 500, 200));
- Pen newpen = new Pen(bru1);
- Point[] p = new Point[] { new Point(0, 0), new Point(100, 100), new Point(50, 100), new Point(200, 100) };
- g.DrawEllipse(newpen,50,50, 100, 100);
- }
附录:
1.
画刷详解:
命名空间: System.Drawing.Drawing2D
SolidBrush:一般的画刷,通常只用一种颜色去填充GDI+图形
创建一般画刷:
SolidBrush sdBrush1 =newSolidBrush(Color); |
HatchBrush:阴影画刷,有两种颜色:前景色和背景色,以及6种阴影。
创建阴影画刷: