C# Graphics 图像管理及常见用法

GDI+:提供了对GDI+基本图形功能的访问,主要有Graphics类、Bitmap类、从Brush类继承的类、Font类、Icon类、Image类、Pen类、Color类等.

  • 创建一个画板主要有3种方式:

    A: 在窗体或控件的Paint事件中直接引用Graphics对象

private void Form1_Paint(object sender, PaintEventArgs e)    
{      
    Graphics g = e.Graphics; //创建画板,这里的画板是由Form提供的.    
}

 B: 利用窗体或某个控件的CreateGraphics方法

Graphics g = this.CreateGraphics();

 C: 从继承自图像的任何对象创建Graphics对象

Image img = Image.FromFile("g1.jpg");//建立Image对象
Graphics g = Graphics.FromImage(img);//创建Graphics对象

Bitmap imgTemp = new Bitmap(2100, 2970);//创建Bitmap 对象
Graphics g_back = Graphics.FromImage(imgTemp);//创建Graphics对象
  • Bitmap 与 Image 之间的转换
  • Image 是抽象类, Bitmap继承自Image。
Image img = this.pictureBox1.Imag
  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值