您当前的位置: 首页 >  c#

彭世瑜

暂无认证

  • 1浏览

    0关注

    2791博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

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

彭世瑜 发布时间:2017-08-19 23:13:20 ,浏览量:1

  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.  
  10. namespace GDIPlusTest
  11. {
  12.     public partial class Form1 : Form
  13.     {
  14.         public Form1()
  15.         {
  16.             InitializeComponent();
  17.         }
  18.  
  19.         private void Form1_Paint(object sender, PaintEventArgs e)
  20.         {
  21.             //创建Graphics对象的三种方式:
  22.             //方式一:
  23.             Graphics g1 = e.Graphics;
  24.  
  25.             //方式二:
  26.             Bitmap img = new Bitmap(200,200);
  27.             Graphics g2 = Graphics.FromImage(img);
  28.  
  29.             //方式三:
  30.             Graphics g3 = this.CreateGraphics();
  31.             
  32.             Pen pen = new Pen(Color.Red,5); //创建画笔        
  33.             g3.DrawEllipse(pen,10,80,200,200);//绘制椭圆
  34.             g3.Dispose();//释放画布
  35.             //MessageBox.Show("Graphics对象创建成功");
  36.         }
  37.     }
  38. }
C#编程-129:Graphics对象
关注
打赏
1665367115
查看更多评论
立即登录/注册

微信扫码登录

0.4879s