1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. namespace GDIPlusTest
  10. {
  11. public partial class Form1 : Form
  12. {
  13. public Form1()
  14. {
  15. InitializeComponent();
  16. }
  17. private void Form1_Paint(object sender, PaintEventArgs e)
  18. {
  19. //创建Graphics对象的三种方式:
  20. //方式一:
  21. Graphics g1 = e.Graphics;
  22. //方式二:
  23. Bitmap img = new Bitmap(200,200);
  24. Graphics g2 = Graphics.FromImage(img);
  25. //方式三:
  26. Graphics g3 = this.CreateGraphics();
  27. Pen pen = new Pen(Color.Red,5); //创建画笔
  28. g3.DrawEllipse(pen,10,80,200,200);//绘制椭圆
  29. g3.Dispose();//释放画布
  30. //MessageBox.Show("Graphics对象创建成功");
  31. }
  32. }
  33. }





C#编程-129:Graphics对象_彭世瑜_新浪博客_aop

C#编程-129:Graphics对象_彭世瑜_新浪博客_对象创建_02
357·309