pictureBox1.Image.Save("f:\\eeee.jpg",pictureBox1.Image.RawFormat);
#region 选中DataGridView一条数据,把图片显示出来
private void dataGridView1_RowEnter(object sender, DataGridViewCellEventArgs e)
{
int rowIndex = e.RowIndex; //获取当前行
string s = dataGridView1.Rows[rowIndex].Cells["xh"].Value.ToString(); //获取当前行xh字段的值
//MessageBox.Show(s);
OracleConnection conn = dbc.getConnection();//获得conn连接
conn.Open();
OracleCommand cmd = conn.CreateCommand();
cmd.CommandText = "SELECT zp FROM kk.kkbj WHERE xh = :xh ";//查询出来图片
cmd.Parameters.Add("xh", OracleType.VarChar).Value = s;//给xh传参
OracleDataReader reader = cmd.ExecuteReader();//创建一个OracleDateReader对象
if (reader.Read())
{
if (reader["zp"] != DBNull.Value)//照片字段里有值才能进到方法体显示图片,否则清空pb
{
MemoryStream ms = new MemoryStream((byte[])reader["zp"]);//把照片读到MemoryStream里
Image imageBlob = Image.FromStream(ms, true);//用流创建Image
pictureBox1.Image = imageBlob;//输出图片
pictureBox1.Image.Save("f:\\eeee.jpg",pictureBox1.Image.RawFormat);
}
else//照片字段里没值,清空pb
{
pictureBox1.Image = null;
}
}
reader.Close();
conn.Close();
}
#endregion
Image image = this.pictureBox1.Image;
string ext = image.RawFormat.ToString();
string path = AppDomain.CurrentDomain.BaseDirectory + "\\Image\\" + textbox1.Text.Trim() +"."+ext;
image.Save(path);
黑色头发:http://heisetoufa.iteye.com