图片加水印、文字加水印

图片加水印

加图片水印:
System.Drawing.Image image
image=System.Drawing.Image.FromFile(path);
    System.Drawing.Image copyImage = System.Drawing.Image.FromFile( Server.MapPath("upload\\126.JPG") );
    Graphics g = Graphics.FromImage(image);
    g.DrawImage(copyImage, new Rectangle(0,0, copyImage.Width, copyImage.Height),  0, 0,  copyImage.Width, copyImage.Height, GraphicsUnit.Pixel);
    g.Dispose();
    image.Save(Server.MapPath(newPath)+System.DateTime.Now.ToString("yyyyMMddHmmss")+exName);
    image.Dispose();
 
加文字水印:
   image=System.Drawing.Image.FromFile(path);
   Graphics g= Graphics.FromImage(image);
   newimage=image.GetThumbnailImage(smallImage_Width,smallImage_Height,callb,new System.IntPtr());
   Font f=new Font(watermark_text_FontName,watermark_text_FontSize,FontStyle.Bold);
   SolidBrush b=new SolidBrush(Color.Red);
   g.DrawString(watermark_text,f,b,10,10);
   g.Dispose();
   image.Save(httpcontent.Server.MapPath(newPath)+System.DateTime.Now.ToString("yyyyMMddHmmss")+exName );
posted @ 2007-02-14 08:47  大牛博客  阅读(380)  评论(0)    收藏  举报