using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Imaging;namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void Form1_Load(object sender, EventArgs e)
{
} private void button1_Click(object sender, EventArgs e)
{
using (SaveFileDialog saveFileDialog1 = new SaveFileDialog())
{
saveFileDialog1.Title = "另存为";
saveFileDialog1.InitialDirectory = @"C:\";
saveFileDialog1.Filter = "图片(*.gif)|*.gif|图片(*.jpg)|*.jpg";
saveFileDialog1.AddExtension = true;
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
using (Image img = pictureBox1.Image)
{
img.Save(saveFileDialog1.FileName);
}
}
}
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Imaging;namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void Form1_Load(object sender, EventArgs e)
{
} private void button1_Click(object sender, EventArgs e)
{
using (SaveFileDialog saveFileDialog1 = new SaveFileDialog())
{
saveFileDialog1.Title = "另存为";
saveFileDialog1.InitialDirectory = @"C:\";
saveFileDialog1.Filter = "图片(*.gif)|*.gif|图片(*.jpg)|*.jpg";
saveFileDialog1.AddExtension = true;
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
using (Image img = pictureBox1.Image)
{
img.Save(saveFileDialog1.FileName);
}
}
}
}
}
}
解决方案 »
- 我的项目中多了一个 TemporaryKey.pfx 文件,有什么用呀,可以删吗?
- 怎么在form2中设置参数后更新form1。。
- 对比字符串值的问题
- 请教一个数据库设计问题,如何设计这样的表?
- 急啊!关于用Micosoft.DirectX.DirectSound录音的问题
- 安装VS.net 2003时提示内部错误25003,网上搜了半天就是找不到解决的方法,求哪位大大帮忙指点一下哦 >.<!
- 如何更改数据窗体向导生成的datagrip的列名
- 请教各位高手关于C#类的问题
- .aspx中的树,有没有办法让其不闪烁呀?
- .net下怎样获取硬盘的序列号,注意不是卷的序列号,最好不用WMI,最好能给出相应代码,谢谢!
- SendMessage 可以在web应用程序中使用吗?
- c#中如何设置启动窗口
C# codeusing System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Imaging;namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void Form1_Load(object sender, EventArgs e)
{
} private void button1_Click(object sender, EventArgs e)
{
using (SaveFileDialog saveFileDialog1 = new SaveFileDialog())
{
saveFileDialog1.Title = "另存为";
saveFileDialog1.InitialDirectory = @"C:\";
saveFileDialog1.Filter = "图片(*.gif)|*.gif|图片(*.jpg)|*.jpg";
saveFileDialog1.AddExtension = true;
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
using (Image img = pictureBox1.Image)
{
img.Save(saveFileDialog1.FileName);
}
}
}
}
}
}
Application.Run(new Form1())参数无效
今天用c#做了个绘图小程序,突然在Application.Run(new Form1());处报错说:参数无效 未处理ArgumentException 找了半天,终于找出了错误。我有在paint事件里用到Graphics,代码如下: private void pictureBox1_Paint(object sender, PaintEventArgs e) { Graphics graphics = e.Graphics;//添加引用,而不是创建新对象,所以不需要多此释放(disponse) Bitmap bitmap_1 = Properties.Resources.p00_1; Bitmap bitmap_2 = Properties.Resources.p01_1; bool aaa = false; for (int i = 1, j = 0; i < 55; j += 12, i++) { if (aaa) { graphics.DrawImage(bitmap_1, 20 + j, 40, 60, 85); aaa = false; } else { graphics.DrawImage(bitmap_2, 20 + j, 40, 60, 85); aaa = true; } } //graphics.Dispose();//出错地方 bitmap_1.Dispose(); bitmap_2.Dispose(); }我把红色的地方注释掉就好了 ,相比大家都看出来了。我试图把一个引用(e.graphics)给释放掉。当然会报错了,希望对朋友们有帮助。