日期:2014-05-17 浏览次数:21200 次
string path = context.Request.PhysicalPath;
string water = context.Server.MapPath("~/image/water.jpg");
Image img = null;
if (!File.Exists(path))
{
string defaultPath = context.Server.MapPath("~/image/default.gif");
img = Image.FromFile(defaultPath);
}
else
{
img = Image.FromFile(path);
Image waterImage = Image.FromFile(water);
Graphics g = Graphics.FromImage(img);
g.DrawImage(waterImage, new Rectangle(img.Width - waterImage.Width, img.Height - waterImage.Height, waterImage.Width, waterImage.Height), new Rectangle(0, 0, waterImage.Width, waterImage.Height), GraphicsUnit.Pixel);
waterImage.Dispose();
g.Dispose();
}
img.Save(context.Response.OutputStream, ImageFormat.Jpeg);
img.Dispose();
context.Response.ContentType = "image/jpeg";
context.Response.End();