国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

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

2024-07-10 13:28:06
字體:
來源:轉載
供稿:網友
這篇文章主要介紹了.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程序設計有一定的借鑒價值。


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 尖扎县| 新乐市| 闽清县| 内丘县| 定南县| 城步| 河东区| 梁河县| 阜新| 宁城县| 连南| 乐昌市| 肥城市| 长汀县| 榆树市| 石林| 夹江县| 晋城| 洪雅县| 静宁县| 垦利县| 武功县| 大同市| 杭州市| 岚皋县| 巢湖市| 南乐县| 五莲县| 勃利县| 扬州市| 邵东县| 黄陵县| 宿迁市| 青海省| 抚松县| 日照市| 抚松县| 搜索| 读书| 临漳县| 临潭县|