加入收藏 | 设为首页 | 会员中心 | 我要投稿 焦作站长网 (https://www.0391zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > Asp教程 > 正文

ASP.NET 2.0,C#----图像特效处理

发布时间:2020-03-19 17:13:29 所属栏目:Asp教程 来源:互联网
导读:ASP.NET 2.0,C#----图像特效处理

}
              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("", "\"));

(编辑:焦作站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

推荐文章
    热点阅读