参考例子写了一个B/S架构下绘制曲线图,并且输出图片的例子,但是在winform下如何输出曲线图呢这是在B/S程序中的代码,放到winform下如何修改?        //保存绘制的图片
        MemoryStream stream = new MemoryStream();
        img.Save(stream, ImageFormat.Jpeg);
        //图片输出
        page.Response.Clear();
        page.Response.ContentType = "image/jpeg";
        page.Response.BinaryWrite(stream.ToArray());   

解决方案 »

  1.   

    输出到哪?如果是文件,Image.Save方法有指定输出文件路径的参数,如果输出到界面,用gdi+画。
      

  2.   

    //start upload
                if(inputCheck==true && fileUnique==true)//Check information complete and unique flag
                {
                try
                {
                    //transfer file data to file stream
                    FileStream fs = new FileStream(strTemp, FileMode.Open, FileAccess.Read);
                    BinaryReader br = new BinaryReader(fs);
                    ptpfile = br.ReadBytes((int)fs.Length);
                    
                    //Create SQL Command
                    StringBuilder strSql = new StringBuilder();
                    strSql.Append("insert into VerControl(ProductName,Version,SubVersion,Filename,Extension,SoftCalData,Description)");
                    strSql.Append(" values('" + txProductName.Text.Trim().ToString() + "','" + txVersion.Text.Trim().ToString() + "',");
                    strSql.Append("'" + txSubVer.Text.Trim().ToString() + "','" + fName.Trim() + "',");
                    strSql.Append("'" + strExtension.Trim() + "',@SoftCalData,");
                    strSql.Append("'" + rtxDesc.Text.Trim().ToString() + "')");                using (SqlCommand cmd = new SqlCommand(strSql.ToString(), sc))
                    {
                        // upload into database
                        sc.Open();
                        cmd.Parameters.Add("@SoftCalData", SqlDbType.Binary).Value = ptpfile;
                        cmd.ExecuteNonQuery();
                        MessageBox.Show("Upload Ok");
                        sc.Close();
                    }
                }
      

  3.   

    附:
    //to store file binary data
            byte[] ptpfile = new byte[0];
      

  4.   

    获取文件路径
    picturebox设置为相应路径即可.