hao_2468

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

1,给图片添加图片水印EmployeeMessage/EditEmployee.aspx


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

}

}

2,实现另存为的效果

这个主题不知道已经被多少人问过多少遍了,无论是ASP.NET,还是PHP还是什么别的CGI,似乎这也算做一个“永恒”的话题了。

其实解决方案很简单(无论哪个CGI平台都是如此),只是一个header而已:
复制C#代码保存代码Response.ContentType = "image/jpeg";
Response.AppendHeader("Content-Disposition","attachment; filename=SailBig.jpg");
Response.TransmitFile( Server.MapPath("~/images/sailbig.jpg") );
Response.End();

posted on 2009-09-11 10:48  hao_2468  阅读(185)  评论(0编辑  收藏  举报