色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

.Net實現上傳圖片按比例自動縮小或放大的方法

本文實例主要展示了.NET實現上傳圖片按比例自動縮小或放大的方法,是非常實用的功能。分享給大家供大家參考之用。具體方法如下:

//// <summary>/// 按比例縮小圖片,自動計算寬度/// </summary>/// <param name="strOldPic">源圖文件名(包括路徑)</param>/// <param name="strNewPic">縮小后保存為文件名(包括路徑)</param>/// <param name="intHeight">縮小至高度</param>public void SmallPicWidth(string strOldPic, string strNewPic, int intHeight){  System.Drawing.Bitmap objPic, objNewPic;  try  { objPic = new System.Drawing.Bitmap(strOldPic); int intWidth = (intHeight / objPic.Height) * objPic.Width; objNewPic = new System.Drawing.Bitmap(objPic, intWidth, intHeight); objNewPic.Save(strNewPic);  }  catch (Exception exp) { throw exp; }  finally  { objPic = null; objNewPic = null;  }}/**//// <summary>/// 縮小圖片/// </summary>/// <param name="strOldPic">源圖文件名(包括路徑)</param>/// <param name="strNewPic">縮小后保存為文件名(包括路徑)</param>/// <param name="intWidth">縮小至寬度</param>/// <param name="intHeight">縮小至高度</param>public void SmallPic(string strOldPic, string strNewPic, int intWidth, int intHeight){  System.Drawing.Bitmap objPic, objNewPic;  try  { objPic = new System.Drawing.Bitmap(strOldPic); objNewPic = new System.Drawing.Bitmap(objPic, intWidth, intHeight); objNewPic.Save(strNewPic);  }  catch (Exception exp) { throw exp; }  finally  { objPic = null; objNewPic = null;  }}

希望本文所述實例對大家的ASP.NET程序設計有一定的借鑒價值。

AspNet技術.Net實現上傳圖片按比例自動縮小或放大的方法,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 西畴县| 贺州市| 城固县| 中宁县| 慈溪市| 定安县| 大石桥市| 同心县| 佛冈县| 宜君县| 称多县| 眉山市| 凤山县| 垦利县| 桦川县| 嘉峪关市| 宜宾县| 额济纳旗| 卫辉市| 会理县| 专栏| 阿坝县| 泽州县| 朝阳县| 武穴市| 西乌| 兴城市| 新巴尔虎右旗| 阿鲁科尔沁旗| 安多县| 弥渡县| 华蓥市| 宣恩县| 张家港市| 凤阳县| 建水县| 纳雍县| 绍兴市| 曲松县| 台安县| 阳朔县|