如何将Graphics中的图像保存呢? Graphics 只是绘图时的 Device Context ,不是图片 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这样保存图像:private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { Bitmap b=new Bitmap(200,200); Graphics g=Graphics.FromImage(b); g.FillRectangle(Brushes.Red,0,0,b.Width,b.Height); Graphics g2=e.Graphics; g2.FillRectangle(Brushes.White,this.ClientRectangle); g2.DrawImage(b,new Rectangle(10,10,b.Width,b.Height)); b.Save("aa.jpg",System.Drawing.Imaging.ImageFormat.Jpeg);//保存图像为aa.jpg b.Dispose(); g2.Dispose(); g.Dispose(); } 大家对构造函数中抛出异常有什么看法? 新手求教。 C#如何利用itextSharp修改现有PDF文件内容!比如插入图片和文字!在线等待!!急!! 怎么获取gridview中最大的年龄 求一C#算法 C#修改进程名 关于C#中的Hashtable 怎么执行脚步? [求助]中文传递的问题,让人苦恼 试问 匹配 任意字符串+空格,这样的表达式如何写? 无法创建C# Project,大家来帮个忙 C#中支持控件数组吗?(在线等候)
private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
Bitmap b=new Bitmap(200,200);
Graphics g=Graphics.FromImage(b);
g.FillRectangle(Brushes.Red,0,0,b.Width,b.Height); Graphics g2=e.Graphics;
g2.FillRectangle(Brushes.White,this.ClientRectangle);
g2.DrawImage(b,new Rectangle(10,10,b.Width,b.Height));
b.Save("aa.jpg",System.Drawing.Imaging.ImageFormat.Jpeg);//保存图像为aa.jpg b.Dispose();
g2.Dispose();
g.Dispose();
}