把字直接写上图片即可。
refer here:
最原创的验证码产生过程,桃花朵朵开 》

解决方案 »

  1.   

    添加水印图片
    一、自定义水印图片方法
    protected void imgBtnPicSet_Click(object sender, ImageClickEventArgs e)
        {
            if (ListBox1.Items.Count > 0)
            {
                //判断在列表框中所选择的单个图片
                if (Session["pic"] != "")
                {
                    //获取所要添加水印文字的图片路径
                    string path = Server.MapPath("File") + "\\" + Session["pic"].ToString();
                    //调用WaterLetter实现水印图片
                    WaterMark(path);
                    //调用自定义getUrl()预览水印后的图片
                    getUrl();
                }
                else
                {
                    Response.Write("<script>alert('请选择列表中一个图片!')</script>");
                }
            }
    }
    二、添加水印图片的透明度合并等操作
      /// 设置水印图片
        /// </summary>
        /// <param name="path">要设置水印图片的路径</param>
        public void WaterMark(string path)
        {
            //获取要水印的图片
            Bitmap bmp = new Bitmap(HttpContext.Current.Server.MapPath(".") + "/Alex.gif");
            //设置水印图片的透明度
            ImageAttributes imageAttr = new ImageAttributes();
            imageAttr.SetColorKey(bmp.GetPixel(20, 20), bmp.GetPixel(20, 20));
            //获取要设置水印图片的扩展名
            string extension = Path.GetExtension(path).ToUpper();
            //设置临时图片名称
            string fileName = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString();
            //初始化要加水印的图片
            System.Drawing.Image image = System.Drawing.Image.FromFile(path);
            //初始化水印图片
            System.Drawing.Image copyImage = System.Drawing.Image.FromFile(HttpContext.Current.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, imageAttr);
            g.Dispose();
            //保存加水印过后的图片,删除原始图片
            string newPath = HttpContext.Current.Server.MapPath(".") + "/" + fileName + "_new" + extension;
            //保存设置完成后的水印图片到临时位置
            image.Save(newPath);
            image.Dispose();
            //CodeGo.net/
            File.Copy(newPath, path, true);
            //删除水印
            if (File.Exists(newPath))
            {
                //删除临时存储的图片
                File.Delete(newPath);
            }
        }