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

 

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

 

asp.net 图片水印+文字水印,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。