图片水印:

     string path = "UploadsImg/" + DateTime.Now.ToString("yyyyMMddHHmmssms") + FileUpload1.FileName;
        //制作画布,将选中的图片流制作成画布
        System.Drawing.Image img = System.Drawing.Image.FromStream(FileUpload1.FileContent);
        //床架绘制对象,指向到画布上
        Graphics g = Graphics.FromImage(img);
        PointF p = new PointF(10, 20);
        System.Drawing.Image logoimg = System.Drawing.Image.FromFile(Server.MapPath("UploadsImg/logo.png"));
        g.DrawImage(logoimg, p);
        img.Save(Server.MapPath(path));
        Image1.ImageUrl = path;

文字水印:

     string path = "UploadsImg/" + DateTime.Now.ToString("yyyyMMddHHmmssms") + FileUpload1.FileName;
     string s = "WWW.ITNBA.COM";
        Font f = new Font("微软雅黑", 55);
        Brush b = new SolidBrush(Color.Red);
        PointF p = new PointF(10, 20);
        //绘制
        g.DrawString(s, f, b, p);
    

 

posted on 2018-01-15 10:48  我勒个去YCQ  阅读(79)  评论(0编辑  收藏  举报