首页 > Web开发 > 详细

asp.net 图片水印+文字水印

时间:2014-05-01 12:05:51      阅读:483      评论:0      收藏:0      [点我收藏+]

 

bubuko.com,布布扣
public void AddWaterPic()
{
    //图片水印
string bg = Request.MapPath("~/images/bg.jpg");//背景图 string newPath = Request.MapPath("~/newImages/");//保存路径 string shuiyin= Request.MapPath("~/images/scrollBlock.jpg");//水印图片 System.Drawing.Image image = System.Drawing.Image.FromFile(bg); //取出背景图片 System.Drawing.Image img = System.Drawing.Image.FromFile(shuiyin);//取出水印图片 Graphics g = Graphics.FromImage(image); Rectangle rectbg = new Rectangle(932, 728, image.Width, image.Height); //水印的坐标宽932,高728 g.DrawImage(img, rectbg , 0, 0, img.Width, img.Height, GraphicsUnit.Pixel); //在指定位置并且按大小绘制水印图片
//文字水印 DateTime dt
= Convert.ToDateTime(Date); g.DrawString(dt.ToString("yyyy年MM月dd日"), f, b, 934, 730); newImageName = (dt.ToString("yyyyMMddhhmmssms") + ".jpg"); System.Drawing.Image cover = System.Drawing.Image.FromFile(newPath + newImageName); Response.ContentType = "image/jpeg";//设置输出类型为JPEG图片 cover.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);//将修改的图片存入输出流 cover.Dispose();//输出图片到客户端 Response.End(); }   
bubuko.com,布布扣

 

asp.net 图片水印+文字水印,布布扣,bubuko.com

asp.net 图片水印+文字水印

原文:http://www.cnblogs.com/Yashull/p/3701419.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!