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

首頁 > 編程 > .NET > 正文

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

2024-07-10 12:43:03
字體:
來源:轉載
供稿:網友

本文實例主要展示了.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程序設計有一定的借鑒價值。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 乌兰浩特市| 固阳县| 乌鲁木齐县| 衡阳市| 双桥区| 建平县| 平罗县| 启东市| 上虞市| 金阳县| 杭锦后旗| 兴和县| 通州区| 宣化县| 东光县| 石嘴山市| 潞城市| 疏勒县| 香河县| 洱源县| 谷城县| 黑山县| 深水埗区| 靖西县| 项城市| 太保市| 微山县| 红河县| 卓尼县| 余姚市| 合江县| 永仁县| 洪雅县| 桐乡市| 宁德市| 彰化县| 黄梅县| 婺源县| 寿宁县| 宜黄县| 沅陵县|