我是这样保存的Bitmap bitmap = new Bitmap(this.pictureBox1.Width, this.pictureBox1.Height);
bitmap = (Bitmap)pictureBox1.Image;
saveFileDialog1.Filter = "JPeg Image|*.jpg|Bitmap Image|*.bmp|Gif Image|*.gif";
saveFileDialog1.Title = "Save an Image File";
saveFileDialog1.ShowDialog();
saveFileDialog1.AddExtension=true;
if(saveFileDialog1.FileName != "")
{
// Saves the Image via a FileStream created by the OpenFile method.
// Saves the Image in the appropriate ImageFormat based upon the
// File type selected in the dialog box.
// NOTE that the FilterIndex property is one-based.
switch(saveFileDialog1.FilterIndex)
{
case 1 :
try
{
bitmap.Save(saveFileDialog1.FileName,
System.Drawing.Imaging.ImageFormat.Jpeg);
}
catch(Exception ee)
{
MessageBox.Show(ee.ToString());
}
break; case 2 :
this.pictureBox1.Image.Save(saveFileDialog1.FileName,
System.Drawing.Imaging.ImageFormat.Bmp);
break; case 3 :
this.pictureBox1.Image.Save(saveFileDialog1.FileName,
System.Drawing.Imaging.ImageFormat.Gif);
break;
bitmap = (Bitmap)pictureBox1.Image;
saveFileDialog1.Filter = "JPeg Image|*.jpg|Bitmap Image|*.bmp|Gif Image|*.gif";
saveFileDialog1.Title = "Save an Image File";
saveFileDialog1.ShowDialog();
saveFileDialog1.AddExtension=true;
if(saveFileDialog1.FileName != "")
{
// Saves the Image via a FileStream created by the OpenFile method.
// Saves the Image in the appropriate ImageFormat based upon the
// File type selected in the dialog box.
// NOTE that the FilterIndex property is one-based.
switch(saveFileDialog1.FilterIndex)
{
case 1 :
try
{
bitmap.Save(saveFileDialog1.FileName,
System.Drawing.Imaging.ImageFormat.Jpeg);
}
catch(Exception ee)
{
MessageBox.Show(ee.ToString());
}
break; case 2 :
this.pictureBox1.Image.Save(saveFileDialog1.FileName,
System.Drawing.Imaging.ImageFormat.Bmp);
break; case 3 :
this.pictureBox1.Image.Save(saveFileDialog1.FileName,
System.Drawing.Imaging.ImageFormat.Gif);
break;
解决方案 »
- 急,一个访问权限问题。
- 指定位置写入文本数据?
- 将参数值从 SqlParameter 转换到 String 失败
- 人人都说CSDN上的人很热情,第一次提问 :)
- 怎么判断接受了多少个字节的数据
- 如何使c#中 textbo类似于excel的单元格那么灵活!自动运算!!!@@@@
- 违反并发性: UpdateCommand 影响了预期 1 条记录中的 0 条
- 请思归大哥进来看看,继续昨天的问题!!谢谢!!在线等到12:00啊!!
- 如何在数据库中添加一条记录的时候同时得到该记录中“自动增长”字段的值?
- 用镜像文件安装,系统提示“内部错误2337”是什么意思?怎么解决阿,不然就无法安装了
- .aspx 的网页里没有任何在服务器端执行的代码,会不会比.html更占用服务器资源?
- C#中的声音问题
楼主可以把对picturebox的画图写到一个类中....
form.cs:有一个调用画图类的函数....这样就可以显示图像了...
单击button:也调用一次画图函数....然后继续执行LZ所贴的代码就可以了...本来想用this.pictureBox1.Refresh();来调用pictureBox1.Paint()事件的...可是它要等到Button.click()全部执行完成才执行...这个方法行不通..所以就想到上面的那个方法了...呵呵..希望有用...
Graphics g=Graphics.FromImage((Image)bitmap);
g.FillRectangle(Brushes.Red,0,0,100,100);
this.pictureBox1.Image=(Image)bitmap;