首页 > 开发 > .Net > 正文

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

2020-04-24 21:58:54
字体:
来源:转载
供稿:网友
利用.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);

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表