您的位置:首页 > 编程语言

添加水印的代码 测试 调试 结果 经过本人亲自测试

2010-03-23 15:14 495 查看
加水印的功能代码如下所示

代码 protected void Button1_Click(object sender, EventArgs e)
{
string extension = Path.GetExtension(this.FileUpload1.FileName).ToUpper();
string fileName = Guid.NewGuid().ToString();
string savePath = Server.MapPath("../upfile/" + fileName+ extension);
if (!Directory.Exists(Path.GetDirectoryName(savePath)))
{
Directory.CreateDirectory(Path.GetDirectoryName(savePath));
}
this.FileUpload1.SaveAs(savePath);

//实例化类
picmark wm = new picmark();

wm.DrawedImagePath = Server.MapPath("/upfile/" + "backlogo.gif") ;
wm.ModifyImagePath = savePath;
wm.RightSpace = 145;
wm.BottoamSpace =17;
wm.LucencyPercent = 50;
wm.OutPath = Server.MapPath("/upfile/" + fileName.Replace("-","").ToUpper() + extension);
wm.DrawImage();

//fileName = "_New_" + fileName;
//string sPath = Server.MapPath("../upfile/" + fileName + extension);
//this.FileUpload1.SaveAs(sPath);

//保存加水印过后的图片,删除原始图片
if (File.Exists(savePath))
{
File.Delete(savePath);
//File.Delete(wm.OutPath);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐