<span id="mktg5"></span>

<i id="mktg5"><meter id="mktg5"></meter></i>

        <label id="mktg5"><meter id="mktg5"></meter></label>
        最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
        問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
        當前位置: 首頁 - 科技 - 知識百科 - 正文

        ASP.NET 2.0,C#----圖像特效處理

        來源:懂視網 責編:小采 時間:2020-11-27 22:45:27
        文檔

        ASP.NET 2.0,C#----圖像特效處理

        ASP.NET 2.0,C#----圖像特效處理:利用.NET 提供的類,如Drawing.Bitmap ,Drawing.Bitmap 等,很容易就可以實現對圖片的簡單處理。包括打水印,放大縮小,等操作。 public partial class WebForm4 : System.Web.UI.Page { // 原始圖片路徑 private string p
        推薦度:
        導讀ASP.NET 2.0,C#----圖像特效處理:利用.NET 提供的類,如Drawing.Bitmap ,Drawing.Bitmap 等,很容易就可以實現對圖片的簡單處理。包括打水印,放大縮小,等操作。 public partial class WebForm4 : System.Web.UI.Page { // 原始圖片路徑 private string p

        利用.NET 提供的類,如Drawing.Bitmap ,Drawing.Bitmap 等,很容易就可以實現對圖片的簡單處理。包括打水印,放大縮小,等操作。

        public partial class WebForm4 : System.Web.UI.Page
              {
                  // 原始圖片路徑
                  private string path;
                  private System.Drawing.Bitmap bitmap;     
                  private System.Drawing.Graphics graphics;
                  string Message = "<script>alert(\"{0}\");</script>";
                  protected void Page_Load(object sender, EventArgs e)
                  {
                      if (!Page.IsPostBack)
                      {
                          this.txtPicPath.Text = Server.MapPath("/test.jpg");
                      }
                      path = this.txtPicPath.Text.Trim();
                      if (!System.IO.File.Exists(path))
                      {
                          MessageShow("指定的源文件不存在!");
                          return;
                      }
                  }
                  // 打水印Logo
                  protected void btnLogo_Click(object sender, EventArgs e)
                  {
                      string log = txtLog.Text.Trim();
                      if (log.Length < 1)
                      {
                          MessageShow("請輸入水印字符!");
                          return;
                      }

                      bitmap = new Bitmap(path);
                      graphics = Graphics.FromImage(bitmap);
                      graphics.DrawString(log, new Font("宋體", 16), System.Drawing.Brushes.GreenYellow, new PointF(bitmap.Width / 2 - (log.Length) * 5, bitmap.Height / 2));
                      try
                      {
                          bitmap.Save(Server.MapPath("./_Log.jpg"), System.Drawing.Imaging.ImageFormat.Jpeg);
                          MessageShow("已經生成水印圖片,路徑為" + @Server.MapPath("./_log.jpg").Replace("\\", "\\\\"));

                      }
                      catch (Exception ex)
                      {
                          MessageShow("生成圖片錯誤!" + ex.Message);
                          throw;
                      }
                      graphics.Dispose();
                      bitmap.Dispose();
                  }
                  private void MessageShow(string msg)
                  {
                      Page.ClientScript.RegisterStartupScript(Page.GetType(), "Message", string.Format(Message, msg));

                  }
                  //放大X*X倍
                  protected void btnBig_Click(object sender, EventArgs e)
                  {
                      int i = int.Parse(txtBig.Text.Trim());
                      System.Drawing.Image img = System.Drawing.Image.FromFile(path);
                      bitmap = new Bitmap(img.Width * i, img.Height * i);
                      graphics = Graphics.FromImage(bitmap);
                      graphics.DrawImage(img, 0, 0, img.Width * i, img.Height * i);
                      try
                      {
                          bitmap.Save(Server.MapPath("./_Big.jpg"), System.Drawing.Imaging.ImageFormat.Jpeg);
                          MessageShow("已經生成圖片,路徑為" + @Server.MapPath("./_Big.jpg").Replace("\\", "\\\\"));

                      }
                      catch (Exception ex)
                      {
                          MessageShow("生成圖片錯誤!" + ex.Message);
                          throw;
                      }
                      graphics.Dispose();
                      bitmap.Dispose();
                  }

                  //縮小為原始圖像的1/(X*X)
                  protected void btnSmall_Click(object sender, EventArgs e)
                  {
                      float i = float.Parse(txtBig.Text.Trim());
                      System.Drawing.Image img = System.Drawing.Image.FromFile(path);
                      int w = Convert.ToInt32(img.Width / i);
                      int h = Convert.ToInt32(img.Height / i);

                      // 防止過度變形
                      if (w < 1) w = 10;
                      if (h < 1) h = 0;
                      bitmap = new Bitmap(w, h);
                      graphics = Graphics.FromImage(bitmap);
                      graphics.DrawImage(img, 0, 0, w, h);
                      try
                      {
                          bitmap.Save(Server.MapPath("./_Small.jpg"), System.Drawing.Imaging.ImageFormat.Jpeg);
                          MessageShow("已經生成圖片,路徑為" + @Server.MapPath("./_Small.jpg").Replace("\\", "\\\\"));

                      }
                      catch (Exception ex)
                      {
                          MessageShow("生成圖片錯誤!" + ex.Message);
                          throw;
                      }
                      graphics.Dispose();
                      bitmap.Dispose();
                  }
        //傾斜( 右轉90度)
                  protected void btnIncline_Click(object sender, EventArgs e)
                  {
                      System.Drawing.Image img = System.Drawing.Image.FromFile(path);
                      // 圖像旋轉,可以利用RotateFlipType的枚舉值,在編程的時候,IDE會自動顯示每一個枚舉的意思
                      img.RotateFlip(RotateFlipType.Rotate90FlipXY);
                      bitmap = new Bitmap(img);
                      graphics = Graphics.FromImage(bitmap);
                      graphics.DrawImage(img, new Point(0, 0));
                      try
                      {
                          bitmap.Save(Server.MapPath("./_Incline.jpg"), System.Drawing.Imaging.ImageFormat.Jpeg);
                          MessageShow("已經生成圖片,路徑為" + @Server.MapPath("./_Incline.jpg").Replace("\\", "\\\\"));

                      }
                      catch (Exception ex)
                      {
                          MessageShow("生成圖片錯誤!" + ex.Message);
                          throw;
                      }
                      graphics.Dispose();
                      bitmap.Dispose();
                  }

                  // 圖像壓扁
                  protected void btnStave_Click(object sender, EventArgs e)
                  {
                      System.Drawing.Image img = System.Drawing.Image.FromFile(path);
                      // 寬度不變
                      int w = img.Width;
                      //    高度為原始高度的1/2
                      int h = img.Height / 2;

                      // 防止過度變形
                      if (w < 1) w = 10;
                      if (h < 1) h = 0;
                      bitmap = new Bitmap(w, h);
                      graphics = Graphics.FromImage(bitmap);
                      graphics.DrawImage(img, 0, 0, w, h);
                      try
                      {
                          bitmap.Save(Server.MapPath("./_Stave.jpg"), System.Drawing.Imaging.ImageFormat.Jpeg);
                          MessageShow("已經生成圖片,路徑為" + @Server.MapPath("./_Stave.jpg").Replace("\\", "\\\\"));

                      }
                      catch (Exception ex)
                      {
                          MessageShow("生成圖片錯誤!" + ex.Message);
                          throw;
                      }
                      graphics.Dispose();
                      bitmap.Dispose();
                  }
                  //圖像拉寬
                  protected void btnElongate_Click(object sender, EventArgs e)
                  {
                      System.Drawing.Image img = System.Drawing.Image.FromFile(path);
                      // 放大寬度
                      int w = img.Width / 2;
                      // 高度不變
                      int h = img.Height;

                      // 防止過度變形
                      if (w < 1) w = 10;
                      if (h < 1) h = 0;
                      bitmap = new Bitmap(w, h);
                      graphics = Graphics.FromImage(bitmap);
                      graphics.DrawImage(img, 0, 0, w, h);
                      try
                      {
                          bitmap.Save(Server.MapPath("./_Elongate.jpg"), System.Drawing.Imaging.ImageFormat.Jpeg);
                          MessageShow("已經生成圖片,路徑為" + @Server.MapPath("./_Elongate.jpg").Replace("\\", "\\\\"));

                      }
                      catch (Exception ex)
                      {
                          MessageShow("生成圖片錯誤!" + ex.Message);
                          throw;
                      }
                      graphics.Dispose();
                      bitmap.Dispose();
                  }
              }

        聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

        文檔

        ASP.NET 2.0,C#----圖像特效處理

        ASP.NET 2.0,C#----圖像特效處理:利用.NET 提供的類,如Drawing.Bitmap ,Drawing.Bitmap 等,很容易就可以實現對圖片的簡單處理。包括打水印,放大縮小,等操作。 public partial class WebForm4 : System.Web.UI.Page { // 原始圖片路徑 private string p
        推薦度:
        標簽: 2.0 圖像處理 c#
        • 熱門焦點

        最新推薦

        猜你喜歡

        熱門推薦

        專題
        Top
        主站蜘蛛池模板: 亚洲国产成人久久精品99| 在线观看免费人成视频色9| 免费va在线观看| 亚洲国产精品日韩av不卡在线| 男女免费观看在线爽爽爽视频 | 久久久久亚洲AV成人无码| 国产成人无码精品久久久久免费| 亚洲AV无码之日韩精品| 中美日韩在线网免费毛片视频 | 免费人成网上在线观看| 中文字幕亚洲一区二区va在线| 国产免费一区二区三区免费视频| 国产亚洲日韩一区二区三区| 两个人的视频www免费| 亚洲人成电影亚洲人成9999网| 久久久精品免费视频| 亚洲欧洲精品国产区| 在线免费观看一级毛片| 亚洲高清毛片一区二区| 亚洲欧洲中文日韩av乱码| 中文字幕久无码免费久久| 亚洲精品线在线观看| 性感美女视频在线观看免费精品 | 亚洲视频免费一区| 国产卡二卡三卡四卡免费网址| 亚洲欧美成人av在线观看| 亚洲人成色7777在线观看不卡| 精品一卡2卡三卡4卡免费视频| 亚洲综合综合在线| 国产在线观看免费完整版中文版| 精品多毛少妇人妻AV免费久久| 中文字幕亚洲色图| 卡1卡2卡3卡4卡5免费视频| 国产精品小视频免费无限app| 久久亚洲国产成人精品性色| 无码国模国产在线观看免费| 9久久免费国产精品特黄| 亚洲小说图片视频| 久久久久亚洲精品天堂久久久久久 | 日本人的色道www免费一区| baoyu777永久免费视频|