using System.Drawing.Imaginghttp://www.c-sharpcorner.com/winforms/ImageViewerST.asp

解决方案 »

  1.   

    Bitmap image=new Bitmap(this.Width,this.Height);
    Graphics gimage=Graphics.FromImage(image);
    gimage.Clear(this.BackColor);
    //gimage.draw...
    image.Save("MyDrawing.jpg",ImageFormat.Jpeg);
      

  2.   

    要存到数据库里,然后可以提出来,谢谢啊,我用的是sqlserver
      

  3.   

    呵呵,果然加分了
    下面是我的一个小程序的代码,你按你的需要改一下就可以了//读取图片字段
    private void ReadPic()
    {
    if (this.BindingContext[sqlDTS,curDaTbl.TableName].Position<0)
    return; SqlConnection sqlConn = new SqlConnection(cmnLib.GetSqlCnn());
    string strQry="select 照片 from CarInfo where 车牌号码='"+this.txt车牌号码.Text+"'";
    SqlCommand sqlCmd = new SqlCommand(strQry, sqlConn);
    object tmpPhoto=null; try
    {
    sqlConn.Open();
    tmpPhoto=sqlCmd.ExecuteScalar();
    sqlConn.Close();
    }
    catch (Exception exp)
    {
    cmnLib.ShowMsg(exp.Message,3);
    } if (tmpPhoto==DBNull.Value)
    {
    picCar.Image=null;
    return;
    } try
    {
    //BLOB is read into Byte array, then used to construct MemoryStream,
    //then passed to PictureBox.
    Byte[] byteBLOBData =  new Byte[0];
    byteBLOBData = (Byte[])tmpPhoto;
    MemoryStream stmBLOBData = new MemoryStream(byteBLOBData);
    picCar.Image= Image.FromStream(stmBLOBData);
    }
    catch(Exception ex)
    {
    cmnLib.ShowMsg(ex.Message);
    }
    }