辞职两个月,网站终于上线,最后一点问题请教
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))
&nb