色尼玛亚洲综合影院,亚洲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實現上傳圖片按比例自動縮小或放大的方法,轉載需保留來源!

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

主站蜘蛛池模板: 新蔡县| 永宁县| 孝昌县| 清河县| 大丰市| 临夏县| 宜州市| 千阳县| 股票| 普安县| 汉阴县| 华阴市| 库车县| 裕民县| 拉孜县| 绩溪县| 白水县| 阿荣旗| 汝阳县| 会泽县| 崇州市| 彭阳县| 昌黎县| 准格尔旗| 留坝县| 巴南区| 利川市| 偃师市| 自治县| 丰原市| 株洲市| 神农架林区| 福清市| 丘北县| 陆良县| 木兰县| 潞西市| 读书| 宜春市| 基隆市| 调兵山市|