使用Drawing类为图片添加图片水印

来源:互联网 发布:美国最新就业数据 编辑:程序博客网 时间:2024/05/17 01:30

//加水印效果

     System.Drawing.Image image = System.Drawing.Image.FromFile(path);
     System.Drawing.Image copyImage = System.Drawing.Image.FromFile( Server.MapPath(".") + "/../../images/copy.gif");
     Graphics g = Graphics.FromImage(image);
     g.DrawImage(copyImage, new Rectangle(image.Width-copyImage.Width, image.Height-copyImage.Height, copyImage.Width, copyImage.Height), 0, 0, copyImage.Width, copyImage.Height, GraphicsUnit.Pixel);
     g.Dispose();
     
     string newPath = Server.MapPath("UploadFile/"+Cyear+"-"+Cmonth+"/")+"9"+newname;
     image.Save(newPath);
     image.Dispose();

     if(File.Exists(path))
     {
      File.Delete(path);
     }
 

原创粉丝点击