http://blog.csdn.net/21aspnet/archive/2007/04/01/1548696.aspx很长时间看清清月儿的这个帖子..虽然时间很久了.但一直也没有更新...不知道为什么这个内容中的最后一个给图片加文字和图片水印的类.我试了好多次.都是错的..哪位大哥可以给个完整的例子...
注意.它的这功能是有图片文字又有文字水印的..这个我特别需要..有多少分算多少分...测试通过..马上结帖!!!!

解决方案 »

  1.   

    using System.Drawing; 
    using System.IO; 
    using System.Drawing.Imaging; 
    private void AddTextToImg(string fileName,string text) 

     if(!File.Exists(MapPath(fileName))) 
     { 
      throw new FileNotFoundException("The file dont exist!"); 
     }  if( text == string.Empty ) 
     { 
      return; 
     } 
     //还需要判断文件类型是否为图像类型,这里就不赘述了 
     System.Drawing.Image image = System.Drawing.Image.FromFile(MapPath(fileName)); 
     Bitmap bitmap = new Bitmap(image,image.Width,image.Height); 
     Graphics g = Graphics.FromImage(bitmap); 
     float fontSize = 12.0f; //字体大小 
     float textWidth = text.Length*fontSize; //文本的长度 
     //下面定义一个矩形区域,以后在这个矩形里画上白底黑字 
     float rectX = 0; 
     float rectY = 0; 
     float rectWidth = text.Length*(fontSize 8); 
     float rectHeight = fontSize 8; 
     //声明矩形域 
     RectangleF textArea = new RectangleF(rectX,rectY,rectWidth,rectHeight); 
     Font font = new Font("宋体",fontSize); //定义字体 
     Brush whiteBrush = new SolidBrush(Color.White); //白笔刷,画文字用 
     Brush blackBrush = new SolidBrush(Color.Black); //黑笔刷,画背景用 
     g.FillRectangle(blackBrush,rectX,rectY,rectWidth,rectHeight); 
     g.DrawString(text,font,whiteBrush,textArea); 
     MemoryStream ms = new MemoryStream( ); 
     //保存为Jpg类型 
     bitmap.Save(ms,ImageFormat.Jpeg); 
     //输出处理后的图像,这里为了演示方便,我将图片显示在页面中了 
     Response.Clear(); 
     Response.ContentType = "image/jpeg"; 
     Response.BinaryWrite( ms.ToArray() ); 
     g.Dispose();  
     bitmap.Dispose(); 
     image.Dispose(); 

      调用时很简单, 
      AddTextToImg("me.jpg","Family.Man"); 
      

  2.   

    http://hi.baidu.com/627195793/blog/item/551ad701f938f88ee950cd9e.html
    看看
      

  3.   

    Asp.net 上传图片添半透明图片或文字水印的方法
      

  4.   

    这东西 网上收收 就来了
    给LZ 两个连接吧  去看看
    http://developer.51cto.com/art/200908/143622.htmhttp://www.cnblogs.com/index/archive/2004/10/20/54498.html
      

  5.   

    public class pic
    {
        private string modifyImagePath = null;
        private string drawedImagePath = null;
        private int rightSpace;
        private int bottoamSpace;
        private int lucencyPercent = 70;
        private string outPath = null;
        public pic()
        {
        }
        public string ModifyImagePath
        {
            get { return this.modifyImagePath; }
            set { this.modifyImagePath = value; }
        }
        public string DrawedImagePath
        {
            get { return this.drawedImagePath; }
            set { this.drawedImagePath = value; }
        }
      
        public int RightSpace
        {
            get { return this.rightSpace; }
            set { this.rightSpace = value; }
        }
        public int BottoamSpace
        {
            get { return this.bottoamSpace; }
            set { this.bottoamSpace = value; }
        }
        public int LucencyPercent
        {
            get { return this.lucencyPercent; }
            set
            {
                if (value >= 0 && value <= 100)
                    this.lucencyPercent = value;
            }
        }
      
        public string OutPath
        {
            get { return this.outPath; }
            set { this.outPath = value; }
        }
        
        public void DrawImage()
        {
            Image modifyImage = null;
            Image drawedImage = null;
            Graphics g = null;
            try
            {
                modifyImage = Image.FromFile(this.ModifyImagePath);
                drawedImage = Image.FromFile(this.DrawedImagePath);
                g = Graphics.FromImage(modifyImage);
                int x = modifyImage.Width - this.rightSpace;
                int y = modifyImage.Height - this.BottoamSpace;
                float[][] matrixItems ={
       new float[] {1, 0, 0, 0, 0},
       new float[] {0, 1, 0, 0, 0},
       new float[] {0, 0, 1, 0, 0},
       new float[] {0, 0, 0, (float)this.LucencyPercent/100f, 0},
       new float[] {0, 0, 0, 0, 1}};
                ColorMatrix colorMatrix = new ColorMatrix(matrixItems);
                ImageAttributes imgAttr = new ImageAttributes();
                imgAttr.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
                g.DrawImage(
                    drawedImage,
                    new Rectangle(x, y, drawedImage.Width, drawedImage.Height),
                    0, 0, drawedImage.Width, drawedImage.Height,
                    GraphicsUnit.Pixel, imgAttr);
                string[] allowImageType ={ ".jpg", ".gif", ".png", ".bmp", ".tiff", ".wmf", ".ico" };
                FileInfo file = new FileInfo(this.ModifyImagePath);
                ImageFormat imageType = ImageFormat.Gif;
                switch (file.Extension.ToLower())
                {
                    case ".jpg":
                        imageType = ImageFormat.Jpeg;
                        break;
                    case ".gif":
                        imageType = ImageFormat.Gif;
                        break;
                    case ".png":
                        imageType = ImageFormat.Png;
                        break;
                    case ".bmp":
                        imageType = ImageFormat.Bmp;
                        break;
                    case ".tif":
                        imageType = ImageFormat.Tiff;
                        break;
                    case ".wmf":
                        imageType = ImageFormat.Wmf;
                        break;
                    case ".ico":
                        imageType = ImageFormat.Icon;
                        break;
                    default:
                        break;
                }
                MemoryStream ms = new MemoryStream();
                modifyImage.Save(ms, imageType);
                byte[] imgData = ms.ToArray();
                modifyImage.Dispose();
                drawedImage.Dispose();
                g.Dispose();
                FileStream fs = null;
                if (this.OutPath == null || this.OutPath == "")
                {
                    File.Delete(this.ModifyImagePath);
                    fs = new FileStream(this.ModifyImagePath, FileMode.Create, FileAccess.Write);
                }
                else
                {
                    fs = new FileStream(this.OutPath, FileMode.Create, FileAccess.Write);
                }
                if (fs != null)
                {
                    fs.Write(imgData, 0, imgData.Length);
                    fs.Close();
                }
            }
            finally
            {
                try
                {
                    drawedImage.Dispose();
                    modifyImage.Dispose();
                    g.Dispose();
                }
                catch { ;}
            }
        }
    }
    类库
      

  6.   

    http://ck275601774.blog.163.com/blog/static/123046801200981594229827/
      

  7.   

    http://www.cnblogs.com/zengxiangzhan/archive/2009/12/27/1633447.html
      

  8.   

    上面传的有点错误,改进过后的:
    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.Drawing;
    using System.IO;
    using System.Drawing.Imaging; 
    public partial class Default5 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            AddTextToImg("2.gif", "Family.Man");     }
        private void AddTextToImg(string fileName,string text) 

     if(!File.Exists(Server.MapPath(fileName))) 
     { 
      throw new FileNotFoundException("The file dont exist!"); 
     }  if( text == string.Empty ) 
     { 
      return; 
     } 
     //还需要判断文件类型是否为图像类型,这里就不赘述了 
     System.Drawing.Image image = System.Drawing.Image.FromFile(MapPath(fileName)); 
     Bitmap bitmap = new Bitmap(image,image.Width,image.Height); 
     Graphics g = Graphics.FromImage(bitmap); 
     float fontSize = 12.0f; //字体大小 
     float textWidth = text.Length*fontSize; //文本的长度 
     //下面定义一个矩形区域,以后在这个矩形里画上白底黑字 
     float rectX = 0; 
     float rectY = 0; 
     float rectWidth = text.Length*(fontSize); 
     float rectHeight = fontSize ; 
     //声明矩形域 
     RectangleF textArea = new RectangleF(rectX,rectY,rectWidth,rectHeight); 
     Font font = new Font("宋体",fontSize); //定义字体 
     Brush whiteBrush = new SolidBrush(Color.White); //白笔刷,画文字用 
     Brush blackBrush = new SolidBrush(Color.Black); //黑笔刷,画背景用 
     g.FillRectangle(blackBrush,rectX,rectY,rectWidth,rectHeight); 
     g.DrawString(text,font,whiteBrush,textArea); 
     MemoryStream ms = new MemoryStream( ); 
     //保存为Jpg类型 
     bitmap.Save(ms,ImageFormat.Jpeg); 
     //输出处理后的图像,这里为了演示方便,我将图片显示在页面中了 
     Response.Clear(); 
     Response.ContentType = "image/jpeg"; 
     Response.BinaryWrite( ms.ToArray() ); 
     g.Dispose();  
     bitmap.Dispose(); 
     image.Dispose(); 
    } }
      

  9.   

    using System;
    using System.Drawing;
    using System.Drawing.Imaging;
    using System.Drawing.Drawing2D;
    using System.Web.UI.WebControls;
    using System.IO;
    /// <summary>
    /// 图片加水印
    /// </summary>
    public class DrawImg
    {
        public DrawImg(string ImageFileName)
        {
            ResourceImage = System.Drawing.Image.FromFile(ImageFileName);
            ErrorMessage = "";
        }    public DrawImg() { }    #region 检测上传文件类型
        /// <summary>
        /// 检查上传文件类型(可以检测真正文件名) 
        /// </summary>
        /// <param name="hifile"></param>
        /// <returns></returns>
        public static bool IsAllowedExtension(FileUpload hifile)
        {
            System.IO.FileStream fs = new System.IO.FileStream(hifile.PostedFile.FileName, System.IO.FileMode.Open, System.IO.FileAccess.Read);
            System.IO.BinaryReader r = new System.IO.BinaryReader(fs);
            string fileclass = "";
            byte buffer;
            try
            {
                buffer = r.ReadByte();
                fileclass = buffer.ToString();
                buffer = r.ReadByte();
                fileclass += buffer.ToString();        }
            catch
            {
            }
            r.Close();
            fs.Close();
            //说明255216是jpg;7173是gif;6677是BMP,13780是PNG;7790是exe,8297是rar
            if (fileclass == "255216" || fileclass == "7173" || fileclass == "6677")
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        #endregion    #region 缩放图品 1.按大小 2.按比例
        public System.Drawing.Image ResourceImage;
        private int ImageWidth;
        private int ImageHeight;
        public string ErrorMessage;    public bool ThumbnailCallback()
        {
            return false;
        }
        // 按大小
        public bool ReducedImage(int Width, int Height, string targetFilePath)
        {
            try
            {
                System.Drawing.Image ReducedImage;
                System.Drawing.Image.GetThumbnailImageAbort callb = new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback);
                ReducedImage = ResourceImage.GetThumbnailImage(Width, Height, callb, IntPtr.Zero);
                ReducedImage.Save(@targetFilePath, ImageFormat.Jpeg);
                ReducedImage.Dispose();
                return true;
            }
            catch (Exception e)
            {
                ErrorMessage = e.Message;
                return false;
            }
        }
        // 按百分比  缩小60% Percent为0.6 targetFilePath为目标路径
        public bool ReducedImage(double Percent, string targetFilePath)
        {
            try
            {
                System.Drawing.Image ReducedImage;
                System.Drawing.Image.GetThumbnailImageAbort callb = new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback);
                ImageWidth = Convert.ToInt32(ResourceImage.Width * Percent);
                ImageHeight = (ResourceImage.Height) * ImageWidth / ResourceImage.Width;//等比例缩放
                ReducedImage = ResourceImage.GetThumbnailImage(ImageWidth, ImageHeight, callb, IntPtr.Zero);
                ReducedImage.Save(@targetFilePath, ImageFormat.Jpeg);
                ReducedImage.Dispose();
                return true;
            }
            catch (Exception e)
            {
                ErrorMessage = e.Message;
                return false;
            }
        }
        #endregion    #region 图片加水印
        private string WorkingDirectory = string.Empty; //路径
        public string PublicWorkingDirectory
        {
            get
            {
                return WorkingDirectory;
            }
            set
            {
                WorkingDirectory = value;
            }
        }
        private string ImageName = string.Empty;   //被处理的图片
        public string PublicImageName
        {
            get
            {
                return ImageName;
            }
            set
            {
                ImageName = value;
            }
        }
        private string ImageWater = string.Empty;  //水印图片
        public string PublicImageWater
        {
            get
            {
                return ImageWater;
            }
            set  //设置了水印图片的话说明是要水印图片效果的
            {
                dealtype = DealType.WaterImage;
                ImageWater = value;
            }
        }
        private string FontString = string.Empty;  //水印文字
        public string PublicFontString
        {
            get
            {
                return FontString;
            }
            set //设置了水印文字的话说明是要水印文字效果的
            {
                dealtype = DealType.WaterFont;
                FontString = value;
            }
        }    enum DealType { NONE, WaterImage, WaterFont, DoubleDo }; //枚举命令
        private DealType dealtype;    public void DealImage()
        {
            IsDouble();        switch (dealtype)
            {
                case DealType.WaterFont: WriteFont(); break;
                case DealType.WaterImage: WriteImg(); break;
                case DealType.DoubleDo: WriteFontAndImg(); break;
            }    }    private void IsDouble()
        {
            if (ImageWater + "" != "" && FontString + "" != "")
            {
                dealtype = DealType.DoubleDo;
            }
        }    private void WriteFont()
        {
            System.Drawing.Image imgPhoto = System.Drawing.Image.FromFile(WorkingDirectory + ImageName);
            int phWidth = imgPhoto.Width;
            int phHeight = imgPhoto.Height;
            Bitmap bmPhoto = new Bitmap(phWidth, phHeight, PixelFormat.Format24bppRgb);
            bmPhoto.SetResolution(imgPhoto.HorizontalResolution, imgPhoto.VerticalResolution);
            Graphics grPhoto = Graphics.FromImage(bmPhoto);
            grPhoto.SmoothingMode = SmoothingMode.AntiAlias;
            grPhoto.DrawImage(
            imgPhoto,                               // Photo Image object
            new Rectangle(0, 0, phWidth, phHeight), // Rectangle structure
            0,                                      // x-coordinate of the portion of the source image to draw. 
            0,                                      // y-coordinate of the portion of the source image to draw. 
            phWidth,                                // Width of the portion of the source image to draw. 
            phHeight,                               // Height of the portion of the source image to draw. 
            GraphicsUnit.Pixel);                    // Units of measure         int[] sizes = new int[] { 16, 14, 12, 10, 8, 6, 4 };
            Font crFont = null;
            SizeF crSize = new SizeF();
            for (int i = 0; i < 7; i++)
            {
                crFont = new Font("arial", sizes[i], FontStyle.Bold);
                crSize = grPhoto.MeasureString(FontString, crFont);
                if ((ushort)crSize.Width < (ushort)phWidth)
                    break;
            }        int yPixlesFromBottom = (int)(phHeight * .05);
            float yPosFromBottom = ((phHeight - yPixlesFromBottom) - (crSize.Height / 2));
            float xCenterOfImg = (phWidth / 2);
            StringFormat StrFormat = new StringFormat();
            StrFormat.Alignment = StringAlignment.Center;
            SolidBrush semiTransBrush2 = new SolidBrush(Color.FromArgb(153, 0, 0, 0));
            grPhoto.DrawString(FontString,
            crFont,
            semiTransBrush2,
            new PointF(xCenterOfImg + 1, yPosFromBottom + 1),
            StrFormat);
            SolidBrush semiTransBrush = new SolidBrush(Color.FromArgb(153, 255, 255, 255));
            grPhoto.DrawString(FontString,
            crFont,
            semiTransBrush,
            new PointF(xCenterOfImg, yPosFromBottom), StrFormat);
            imgPhoto = bmPhoto;
            grPhoto.Dispose();
            imgPhoto.Save(WorkingDirectory + ImageName + "_finally.jpg", ImageFormat.Jpeg);
            imgPhoto.Dispose();
            string filename = WorkingDirectory + ImageName;
            File.Delete(WorkingDirectory + ImageName);
        }
     
      

  10.   

       private void WriteImg()
        {
            System.Drawing.Image imgPhoto = System.Drawing.Image.FromFile(WorkingDirectory + ImageName);
            int phWidth = imgPhoto.Width;
            int phHeight = imgPhoto.Height;
            Bitmap bmPhoto = new Bitmap(phWidth, phHeight, PixelFormat.Format24bppRgb);
            bmPhoto.SetResolution(imgPhoto.HorizontalResolution, imgPhoto.VerticalResolution);
            Graphics grPhoto = Graphics.FromImage(bmPhoto);
            System.Drawing.Image imgWater = new Bitmap(WorkingDirectory + ImageWater);
            int wmWidth = imgWater.Width;
            int wmHeight = imgWater.Height;
            grPhoto.SmoothingMode = SmoothingMode.AntiAlias;
            grPhoto.DrawImage(
            imgPhoto,                               // Photo Image object
            new Rectangle(0, 0, phWidth, phHeight), // Rectangle structure
            0,                                      // x-coordinate of the portion of the source image to draw. 
            0,                                      // y-coordinate of the portion of the source image to draw. 
            phWidth,                                // Width of the portion of the source image to draw. 
            phHeight,                               // Height of the portion of the source image to draw. 
            GraphicsUnit.Pixel);                    // Units of measure         Bitmap bmWater = new Bitmap(bmPhoto);
            bmWater.SetResolution(imgPhoto.HorizontalResolution, imgPhoto.VerticalResolution);
            //Load this Bitmap into a new Graphic Object
            Graphics grWater = Graphics.FromImage(bmWater);
            ImageAttributes imageAttributes = new ImageAttributes();
            ColorMap colorMap = new ColorMap();
            colorMap.OldColor = Color.FromArgb(255, 0, 255, 0);
            colorMap.NewColor = Color.FromArgb(0, 0, 0, 0);
            ColorMap[] remapTable = { colorMap };
            imageAttributes.SetRemapTable(remapTable, ColorAdjustType.Bitmap);
            float[][] colorMatrixElements = { 
               new float[] {1.0f,  0.0f,  0.0f,  0.0f, 0.0f},       
               new float[] {0.0f,  1.0f,  0.0f,  0.0f, 0.0f},        
               new float[] {0.0f,  0.0f,  1.0f,  0.0f, 0.0f},        
               new float[] {0.0f,  0.0f,  0.0f,  0.3f, 0.0f},        
               new float[] {0.0f,  0.0f,  0.0f,  0.0f, 1.0f}};
            ColorMatrix wmColorMatrix = new ColorMatrix(colorMatrixElements);
            imageAttributes.SetColorMatrix(wmColorMatrix, ColorMatrixFlag.Default,
            ColorAdjustType.Bitmap);
            int xPosOfWm = ((phWidth - wmWidth) - 10);
            int yPosOfWm = 10;        grWater.DrawImage(imgWater,
            new Rectangle(xPosOfWm, yPosOfWm, wmWidth, wmHeight),  //Set the detination Position
            0,                  // x-coordinate of the portion of the source image to draw. 
            0,                  // y-coordinate of the portion of the source image to draw. 
            wmWidth,            // Water Width
            wmHeight,      // Water Height
            GraphicsUnit.Pixel, // Unit of measurment
            imageAttributes);   //ImageAttributes Object
            //Replace the original photgraphs bitmap with the new Bitmap
            imgPhoto = bmWater;
            grPhoto.Dispose();
            grWater.Dispose();
            imgPhoto.Save(WorkingDirectory + ImageName + "_finally.jpg", ImageFormat.Jpeg);
            imgPhoto.Dispose();
            imgWater.Dispose();
            string filename = WorkingDirectory + ImageName;
            File.Delete(WorkingDirectory + ImageName);
        }    private void WriteFontAndImg()
        {
            System.Drawing.Image imgPhoto = System.Drawing.Image.FromFile(WorkingDirectory + ImageName);
            int phWidth = imgPhoto.Width;
            int phHeight = imgPhoto.Height;
            Bitmap bmPhoto = new Bitmap(phWidth, phHeight, PixelFormat.Format24bppRgb);
            bmPhoto.SetResolution(imgPhoto.HorizontalResolution, imgPhoto.VerticalResolution);
            Graphics grPhoto = Graphics.FromImage(bmPhoto);
            Bitmap imgWater = new Bitmap(WorkingDirectory + ImageWater);
            int wmWidth = imgWater.Width;
            int wmHeight = imgWater.Height;
            grPhoto.SmoothingMode = SmoothingMode.AntiAlias;
            grPhoto.DrawImage(
            imgPhoto,                               // Photo Image object
            new Rectangle(0, 0, phWidth, phHeight), // Rectangle structure
            0,                                      // x-coordinate of the portion of the source image to draw. 
            0,                                      // y-coordinate of the portion of the source image to draw. 
            phWidth,                                // Width of the portion of the source image to draw. 
            phHeight,                               // Height of the portion of the source image to draw. 
            GraphicsUnit.Pixel);                    // Units of measure         int[] sizes = new int[] { 16, 14, 12, 10, 8, 6, 4 };
            Font crFont = null;
            SizeF crSize = new SizeF();
            for (int i = 0; i < 7; i++)
            {
                crFont = new Font("arial", sizes[i], FontStyle.Bold);
                crSize = grPhoto.MeasureString(FontString, crFont);
                if ((ushort)crSize.Width < (ushort)phWidth)
                    break;
            }
            int yPixlesFromBottom = (int)(phHeight * .05);
            float yPosFromBottom = ((phHeight - yPixlesFromBottom) - (crSize.Height / 2));
            float xCenterOfImg = (phWidth / 2);
            StringFormat StrFormat = new StringFormat();
            StrFormat.Alignment = StringAlignment.Center;
            SolidBrush semiTransBrush2 = new SolidBrush(Color.FromArgb(153, 0, 0, 0));
            grPhoto.DrawString(FontString,                 //string of text
            crFont,                                   //font
            semiTransBrush2,                           //Brush
            new PointF(xCenterOfImg + 1, yPosFromBottom + 1),  //Position
            StrFormat);        SolidBrush semiTransBrush = new SolidBrush(Color.FromArgb(153, 255, 255, 255));
            grPhoto.DrawString(FontString,                 //string of text
            crFont,                                   //font
            semiTransBrush,                           //Brush
            new PointF(xCenterOfImg, yPosFromBottom),  //Position
            StrFormat);                               //Text alignment        Bitmap bmWater = new Bitmap(bmPhoto);
            bmWater.SetResolution(imgPhoto.HorizontalResolution, imgPhoto.VerticalResolution);
            Graphics grWater = Graphics.FromImage(bmWater);
            ImageAttributes imageAttributes = new ImageAttributes();
            ColorMap colorMap = new ColorMap();
            colorMap.OldColor = Color.FromArgb(255, 0, 255, 0);
            colorMap.NewColor = Color.FromArgb(0, 0, 0, 0);
            ColorMap[] remapTable = { colorMap };
            imageAttributes.SetRemapTable(remapTable, ColorAdjustType.Bitmap);
            float[][] colorMatrixElements = { 
               new float[] {1.0f,  0.0f,  0.0f,  0.0f, 0.0f},       
               new float[] {0.0f,  1.0f,  0.0f,  0.0f, 0.0f},        
               new float[] {0.0f,  0.0f,  1.0f,  0.0f, 0.0f},        
               new float[] {0.0f,  0.0f,  0.0f,  0.3f, 0.0f},        
               new float[] {0.0f,  0.0f,  0.0f,  0.0f, 1.0f}};
            ColorMatrix wmColorMatrix = new ColorMatrix(colorMatrixElements);
            imageAttributes.SetColorMatrix(wmColorMatrix, ColorMatrixFlag.Default,
            ColorAdjustType.Bitmap);
            int xPosOfWm = ((phWidth - wmWidth) - 10);
            int yPosOfWm = 10;        grWater.DrawImage(imgWater,
            new Rectangle(xPosOfWm, yPosOfWm, wmWidth, wmHeight),  //Set the detination Position
            0,                  // x-coordinate of the portion of the source image to draw. 
            0,                  // y-coordinate of the portion of the source image to draw. 
            wmWidth,            // Water Width
            wmHeight,      // Water Height
            GraphicsUnit.Pixel, // Unit of measurment
            imageAttributes);   //ImageAttributes Object        imgPhoto = bmWater;
            grPhoto.Dispose();
            grWater.Dispose();
            imgPhoto.Save(WorkingDirectory + ImageName + "_finally.jpg", ImageFormat.Jpeg);
            imgPhoto.Dispose();
        }
        #endregion}
      

  11.   

    给你参考一下。看看这个符合你的要求吗??
    http://www.cnblogs.com/ywqu/archive/2008/11/27/1330747.html
    http://www.cnblogs.com/index/archive/2004/10/20/54498.html
    如有错误,还请见谅。。
      

  12.   

    清清月儿的帖子看了思路是: 先使用Graphics 类画一个水印图片,然后使用Graphics.FromImage("imageName")打开需要添加水印的图片,进而把水印图片画到图片里。主要就是Graphics 类的使用。 你看下如何使用Graphics 画图就明白了
      

  13.   

     public void AddWaterMark(string docName, string FilePath, string SavePath, string content)
        {
            System.Windows.Forms.Application.DoEvents();
            object Nothing = System.Reflection.Missing.Value;
            object filename = FilePath + "\\" + docName;
            object docname = SavePath + "\\" + docName;
            //图片存放位置 
            //String logoPath = "E:\\111.jpg";
            Microsoft.Office.Interop.Word.Application WordApp = new Microsoft.Office.Interop.Word.ApplicationClass();
            Microsoft.Office.Interop.Word.Document WordDoc = WordApp.Documents.Open(ref filename, ref Nothing, ref Nothing,
                ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing,
                ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing);
            try
            {
                WordDoc.Application.ActiveWindow.Selection.Range.Select();
                WordDoc.Application.ActiveWindow.ActivePane.View.SeekView = Microsoft.Office.Interop.Word.WdSeekView.wdSeekCurrentPageHeader;
                //增加水印图片 
                //WordDoc.Application.Selection.HeaderFooter.Shapes.AddPicture(logoPath, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing).Select(ref Nothing);
                //增加水印文字 
                WordDoc.Paragraphs.Last.Range.Text = "这是kk加的内容";
                //string str = "";
                //if(Session["QianZi"].ToString()!=null)
                //{
                //     str = "../general/QianZi"+Session["QianZi"].ToString();
                //}            object a = true;
                object b = true;
                object left = null;
                object top = null;
                object width = 300;
                object height = 150;
                String str = "E:\\111.jpg";
                WordDoc.Shapes.AddPicture(str, ref  a, ref  b, ref  left, ref  top, ref    width, ref    height, ref  Nothing);
                WordDoc.Application.Selection.HeaderFooter.Shapes.AddTextEffect(MsoPresetTextEffect.msoTextEffect13, content, "隶书", (float)40, MsoTriState.msoTrue, MsoTriState.msoFalse, 0, 0, ref Nothing).Select(ref Nothing);
                WordDoc.Application.Selection.ShapeRange.Name = "WordPictureWater1";
                WordDoc.Application.Selection.ShapeRange.LockAspectRatio = MsoTriState.msoTrue;
                WordDoc.Application.Selection.ShapeRange.Height = 100f;
                WordDoc.Application.Selection.ShapeRange.Width = 100f;
                WordDoc.Application.Selection.ShapeRange.Left = 350f; //WdShapePosition.wdShapeCenter;居中 
                WordDoc.Application.Selection.ShapeRange.Top = 550f;// WdShapePosition.wdShapeCenter;居中 
                WordDoc.Application.Selection.ShapeRange.WrapFormat.AllowOverlap = 0;
                WordDoc.Application.Selection.ShapeRange.LayoutInCell = 0;
                WordDoc.Application.Selection.ShapeRange.WrapFormat.Side = WdWrapSideType.wdWrapBoth;
                WordDoc.Application.Selection.ShapeRange.WrapFormat.Type = WdWrapType.wdWrapNone;                  // 
                WordDoc.Application.Selection.ShapeRange.ZOrder(MsoZOrderCmd.msoSendBehindText);//文本底下 
                WordDoc.Application.Selection.ShapeRange.RelativeHorizontalPosition = WdRelativeHorizontalPosition.wdRelativeHorizontalPositionPage;
                WordDoc.Application.Selection.ShapeRange.RelativeVerticalPosition = WdRelativeVerticalPosition.wdRelativeVerticalPositionPage;
                WordDoc.Application.ActiveWindow.ActivePane.View.SeekView = WdSeekView.wdSeekMainDocument;
                WordDoc.SaveAs(ref docname, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing);
                WordDoc.Close(ref Nothing, ref Nothing, ref Nothing);
                WordApp.Quit(ref Nothing, ref Nothing, ref Nothing);
            }
            catch (Exception ee)
            {        }
            finally
            {        }    }
      

  14.   

    http://www.51aspx.com/S/%E6%B0%B4%E5%8D%B0.html
    你可以这里看看