服务导航
企业概况     李墨菲博客
百度推广、谷歌推广、SEO优化
域名注册、服务器 VPS租用
网站服务流程    业务渠道代理
网站建设价格表
搜索引擎竞价排名服务
800元企业网站制作特价套餐
搜索引擎免费登录口
咨询QQ:2196677
售后QQ:82090889
为什么要选择八桂网讯?
8年品牌网站建设经验积累,网站成功客户超2200家!
在为您提供服务的任何一个环节,我们都拥有自己的核心团队,保障售后服务的可控性。
由程序编程师、平面美工设计师形成的专业后盾组合,从asp、asp.net、php到java的知识结构互补,使得八桂网讯能够满足客户的功能需求和二次开发整合。
全面的成熟团队为能为您提供一流的平面设计和网站管理后台。
当前位置:网站首页 新闻资讯加文字水印和图片水印代码
加文字水印和图片水印代码
编辑:八桂网讯    时间:2009/5/24    浏览:1956
private void Btn_Upload_Click(object sender, System.EventArgs e) { if(UploadFile.PostedFile.FileName.Trim()!="") { //上传文件 string extension = Path.GetExtension(UploadFile.PostedFile.FileName).ToUpper(); string fileName = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString(); string path = Server.MapPath(".") + "/UploadFile/" + fileName + extension; UploadFile.PostedFile.SaveAs(path); //加文字水印,注意,这里的代码和以下加图片水印的代码不能共存 System.Drawing.Image image = System.Drawing.Image.FromFile(path); Graphics g = Graphics.FromImage(image); g.DrawImage(image, 0, 0, image.Width, image.Height); Font f = new Font("Verdana", 32); Brush b = new SolidBrush(Color.White); string addText = AddText.Value.Trim(); g.DrawString(addText, f, b, 10, 10); g.Dispose(); //加图片水印 System.Drawing.Image image = System.Drawing.Image.FromFile(path); System.Drawing.Image copyImage = System.Drawing.Image.FromFile( Server.MapPath(".") + "/Alex.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/" + fileName + "_new" + extension; image.Save(newPath); image.Dispose(); if(File.Exists(path)) { File.Delete(path); } Response.Redirect(newPath); } }
八桂网讯 爱伦文化 深圳外语培训 招商加盟 迪优目录 广西旅游365 八桂大地 建站导航网 南宁创意雕塑 双成纸管
八桂网讯-高端网站建设专家
Copyright © 2004- 八桂网讯网络技术有限公司 Baguidadi Inc. All Rights Reserved.