<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關(guān)鍵字專題1關(guān)鍵字專題50關(guān)鍵字專題500關(guān)鍵字專題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關(guān)鍵字專題關(guān)鍵字專題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
        當(dāng)前位置: 首頁(yè) - 科技 - 知識(shí)百科 - 正文

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

        來源:懂視網(wǎng) 責(zé)編:小采 時(shí)間:2020-11-27 22:45:27
        文檔

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

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

        利用.NET 提供的類,如Drawing.Bitmap ,Drawing.Bitmap 等,很容易就可以實(shí)現(xiàn)對(duì)圖片的簡(jiǎn)單處理。包括打水印,放大縮小,等操作。

        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("請(qǐng)輸入水印字符!");
                          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("已經(jīng)生成水印圖片,路徑為" + @Server.MapPath("./_log.jpg").Replace("\\", "\\\\"));

                      }
                      catch (Exception ex)
                      {
                          MessageShow("生成圖片錯(cuò)誤!" + 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("已經(jīng)生成圖片,路徑為" + @Server.MapPath("./_Big.jpg").Replace("\\", "\\\\"));

                      }
                      catch (Exception ex)
                      {
                          MessageShow("生成圖片錯(cuò)誤!" + 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("已經(jīng)生成圖片,路徑為" + @Server.MapPath("./_Small.jpg").Replace("\\", "\\\\"));

                      }
                      catch (Exception ex)
                      {
                          MessageShow("生成圖片錯(cuò)誤!" + ex.Message);
                          throw;
                      }
                      graphics.Dispose();
                      bitmap.Dispose();
                  }
        //傾斜( 右轉(zhuǎn)90度)
                  protected void btnIncline_Click(object sender, EventArgs e)
                  {
                      System.Drawing.Image img = System.Drawing.Image.FromFile(path);
                      // 圖像旋轉(zhuǎn),可以利用RotateFlipType的枚舉值,在編程的時(shí)候,IDE會(huì)自動(dòng)顯示每一個(gè)枚舉的意思
                      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("已經(jīng)生成圖片,路徑為" + @Server.MapPath("./_Incline.jpg").Replace("\\", "\\\\"));

                      }
                      catch (Exception ex)
                      {
                          MessageShow("生成圖片錯(cuò)誤!" + 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("已經(jīng)生成圖片,路徑為" + @Server.MapPath("./_Stave.jpg").Replace("\\", "\\\\"));

                      }
                      catch (Exception ex)
                      {
                          MessageShow("生成圖片錯(cuò)誤!" + 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("已經(jīng)生成圖片,路徑為" + @Server.MapPath("./_Elongate.jpg").Replace("\\", "\\\\"));

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

        聲明:本網(wǎng)頁(yè)內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

        文檔

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

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

        最新推薦

        猜你喜歡

        熱門推薦

        專題
        Top
        主站蜘蛛池模板: 亚洲一区二区三区免费| 成人一a毛片免费视频| 1000部羞羞禁止免费观看视频| 一个人免费日韩不卡视频| 最近中文字幕免费2019| 午夜宅男在线永久免费观看网| 在线看片无码永久免费aⅴ | 久久免费视频网站| 日本最新免费网站| 美女黄网站人色视频免费国产| 亚洲免费一区二区| 亚洲午夜精品久久久久久app| 亚洲日韩在线中文字幕综合| 免费国产va在线观看| 免费的全黄一级录像带| 国产成人无码免费看视频软件 | 亚洲精品国产精品乱码不卡| 亚洲啪啪综合AV一区| 亚洲国产精品午夜电影| 色天使色婷婷在线影院亚洲 | 免费大片黄在线观看| 永久免费AV无码网站国产| 色婷婷7777免费视频在线观看| 亚洲不卡无码av中文字幕| 亚洲国产成人久久精品影视| 亚洲一区精彩视频| 亚洲av无码av制服另类专区| 亚洲天堂一区在线| 最好2018中文免费视频| 91精品国产免费久久国语麻豆| 国产精品免费一级在线观看| 日韩va亚洲va欧洲va国产| 亚洲一久久久久久久久| baoyu777永久免费视频 | 伊伊人成亚洲综合人网7777| 91亚洲国产在人线播放午夜| 欧洲亚洲国产精华液| 免费无码一区二区三区| 日本中文一区二区三区亚洲| 亚洲综合久久久久久中文字幕| 污网站在线免费观看|