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

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

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

//// <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程序設(shè)計有一定的借鑒價值。

AspNet技術(shù).Net實現(xiàn)上傳圖片按比例自動縮小或放大的方法,轉(zhuǎn)載需保留來源!

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

主站蜘蛛池模板: 虞城县| 永春县| 贵德县| 华坪县| 郸城县| 宁蒗| 毕节市| 沙雅县| 亳州市| 陆良县| 定边县| 比如县| 清镇市| 宁远县| 通江县| 阿拉善右旗| 霞浦县| 绥宁县| 门头沟区| 海晏县| 蒙城县| 武冈市| 临夏县| 林甸县| 周口市| 永德县| 布尔津县| 崇义县| 霍邱县| 修武县| 青阳县| 北安市| 如东县| 白城市| 海宁市| 哈密市| 泸水县| 桐柏县| 青河县| 广饶县| 琼海市|