本帖最后由 legends2012 于 2014-02-17 22:20:42 编辑

解决方案 »

  1.   

    我也遇到了这样的情况,是这样解决的:
    在输出文本之前加上下面这句代码
    g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
      

  2.   

            /**/
            /// <summary>
            /// 水印文字是否使用阴影
            /// </summary>
            public bool Shadow { get; set; }Shadow=false
      

  3.   

    在图片上添加水印图片
    /// <summary>
        /// 设置水印图片
        /// </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();
            //
            File.Copy(newPath, path, true);
            //删除水印
            if (File.Exists(newPath))
            {
                //删除临时存储的图片
                File.Delete(newPath);
            }
        }