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

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

主站蜘蛛池模板: 咸宁市| 封丘县| 大余县| 绥江县| 大余县| 桂阳县| 万山特区| 鹤岗市| 泾源县| 金坛市| 腾冲县| 峨边| 衡阳县| 昭觉县| 韩城市| 杭锦后旗| 六安市| 云林县| 略阳县| 大埔区| 怀柔区| 泸定县| 叶城县| 宜州市| 穆棱市| 汉沽区| 稻城县| 肃宁县| 兴安盟| 清远市| 龙江县| 陆河县| 平和县| 汤阴县| 平湖市| 桦川县| 辛集市| 游戏| 阜城县| 太仆寺旗| 山丹县|