标签:style blog http color os ar for strong sp
知识点:
1.先创建一个Image,再创建一个水印图片Image,再创建画布Graphic
问题:
图片上放置一个水印图片
解决方案
1 <%@ WebHandler Language="C#" Class="ShuiYin" %> 2 3 using System; 4 using System.Web; 5 using System.Drawing; 6 7 public class ShuiYin : IHttpHandler { 8 9 public void ProcessRequest (HttpContext context) { 10 context.Response.ContentType = "text/jpeg"; 11 //context.Response.Write("Hello World"); 12 //读取原图 13 using (Image img=System.Drawing.Image.FromFile(context.Server.MapPath("download/1.jpg"))) 14 { 15 //读取水印图片 16 using (Image imgWater=Image.FromFile(context.Server.MapPath("download/2.jpg"))) 17 { 18 //创建一个“画布” 19 using (Graphics g=Graphics.FromImage(img)) 20 { 21 //把水印图片画到“原图”上 22 g.DrawImage(imgWater,new Rectangle(100,100,imgWater.Width,img.Height),new Rectangle(0,0,imgWater.Width,imgWater.Height),GraphicsUnit.Pixel); 23 } 24 img.Save(context.Response.OutputStream,System.Drawing.Imaging.ImageFormat.Jpeg); 25 } 26 } 27 } 28 29 public bool IsReusable { 30 get { 31 return false; 32 } 33 } 34 35 }
标签:style blog http color os ar for strong sp
原文地址:http://www.cnblogs.com/weijieAndy/p/4034193.html