国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
用C#實現(xiàn)圖片的縮放
  1. class ExampleOfLegalsoft   
  2. {   
  3.      //************************************************************//   
  4.      //下面給出三個簡單的方法,后面兩個方法是擴展,估計有時用得著   
  5.      //************************************************************//   
  6.      /// <summary>   
  7.      /// 縮小圖片   
  8.      /// </summary>   
  9.      /// <param name="strOldPic">源圖文件名(包括路徑)</param>   
  10.      /// <param name="strNewPic">縮小后保存為文件名(包括路徑)</param>   
  11.      /// <param name="intWidth">縮小至寬度</param>   
  12.      /// <param name="intHeight">縮小至高度</param>   
  13.      public void SmallPic(string strOldPic, string strNewPic, int intWidth, int intHeight)   
  14.      {   
  15.           System.Drawing.Bitmap objPic, objNewPic;   
  16.           try  
  17.           {   
  18.                 objPic = new System.Drawing.Bitmap(strOldPic);   
  19.                 objNewPic = new System.Drawing.Bitmap(objPic, intWidth, intHeight);   
  20.                 objNewPic.Save(strNewPic);   
  21.           }   
  22.           catch (Exception exp) { throw exp; }   
  23.           finally  
  24.           {   
  25.                 objPic = null;   
  26.                 objNewPic = null;   
  27.           }   
  28.      }   
  29.      /// <summary>   
  30.      /// 按比例縮小圖片,自動計算高度   
  31.      /// </summary>   
  32.      /// <param name="strOldPic">源圖文件名(包括路徑)</param>   
  33.      /// <param name="strNewPic">縮小后保存為文件名(包括路徑)</param>   
  34.      /// <param name="intWidth">縮小至寬度</param>   
  35.      public void SmallPic(string strOldPic, string strNewPic, int intWidth)   
  36.      {   
  37.           System.Drawing.Bitmap objPic, objNewPic;   
  38.           try  
  39.           {   
  40.                 objPic = new System.Drawing.Bitmap(strOldPic);   
  41.                 int intHeight = (intWidth / objPic.Width) * objPic.Height;   
  42.                 objNewPic = new System.Drawing.Bitmap(objPic, intWidth, intHeight);   
  43.                 objNewPic.Save(strNewPic);   
  44.           }   
  45.           catch (Exception exp) { throw exp; }   
  46.           finally  
  47.           {   
  48.                 objPic = null;   
  49.                 objNewPic = null;   
  50.           }   
  51.      }   
  52.      /// <summary>   
  53.      /// 按比例縮小圖片,自動計算寬度   
  54.      /// </summary>   
  55.      /// <param name="strOldPic">源圖文件名(包括路徑)</param>   
  56.      /// <param name="strNewPic">縮小后保存為文件名(包括路徑)</param>   
  57.      /// <param name="intHeight">縮小至高度</param>   
  58.      public void SmallPic(string strOldPic, string strNewPic, int intHeight)   
  59.      {   
  60.           System.Drawing.Bitmap objPic, objNewPic;   
  61.           try  
  62.           {   
  63.                 objPic = new System.Drawing.Bitmap(strOldPic);   
  64.                 int intWidth = (intHeight / objPic.Height) * objPic.Width;   
  65.                 objNewPic = new System.Drawing.Bitmap(objPic, intWidth, intHeight);   
  66.                 objNewPic.Save(strNewPic);   
  67.           }   
  68.           catch (Exception exp) { throw exp; }   
  69.           finally  
  70.           {   
  71.                 objPic = null;   
  72.                 objNewPic = null;   
  73.           }   
  74.      }   
  75. }
本站僅提供存儲服務,所有內容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權內容,請點擊舉報。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
C# :實現(xiàn)水印與圖片合成,并利用Graphics 壓縮圖像質量 , (委托實現(xiàn)listB...
C#手動自動保存圖片
Android_UI開發(fā)專題
jJavaScript重新設置網頁窗口大小
WEB打印控件Lodop(V6.x)使用說明及樣例
DataGridView 中單元格顯示不一樣顏色方法
更多類似文章 >>
生活服務
分享 收藏 導長圖 關注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服