当前位置: 代码迷 >> ASP.NET >> 辞职两个月,网站终于下线,最后一点有关问题请问
  详细解决方案

辞职两个月,网站终于下线,最后一点有关问题请问

热度:8298   发布时间:2013-02-25 00:00:00.0
辞职两个月,网站终于上线,最后一点问题请教
 public static string UploadImage(HttpPostedFileBase UploadFile, int userid, int tWidth = 400, int tHeight = 400, string path = "/content/userhead/")
        {
            string result = "";
            System.IO.Stream oStream = null;
            System.Drawing.Image oImage = null;
            using (oStream = UploadFile.InputStream)
            {
                using (System.Drawing.Image img11 = System.Drawing.Image.FromStream(oStream))
                {
                    oImage = new System.Drawing.Bitmap(img11);
                    img11.Dispose();
                    oStream.Dispose();

                    int oWidth = oImage.Width;
                    int oHeight = oImage.Height;
                    if (oWidth < tWidth && oHeight < tHeight)
                    {
                        return result;
                    }
                    if (oWidth >= oHeight)
                        tHeight = (int)Math.Floor(Convert.ToDouble(oHeight) * (Convert.ToDouble(tWidth) / Convert.ToDouble(oWidth)));
                    else
                        tWidth = (int)Math.Floor(Convert.ToDouble(oWidth) * (Convert.ToDouble(tHeight) / Convert.ToDouble(oHeight)));

                    Bitmap tImage = new Bitmap(tWidth, tHeight);//70x70
                    using (Graphics g = Graphics.FromImage(tImage))
                    {
                        g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High; //设置高质量插值法 
  相关解决方案