Corresponding code download: http://download.csdn.net/source/1210790
//original picture public void Originalimage () {String SourcePath = @ "... /.. /resources/test.jpg "; System.Drawing.Image Image = System.Drawing.Image.FromFile (SourcePath); Resultimage.image = Image; ///Add text watermark public void Makewordwatermark () {String SourcePath = @ "... /.. /resources/test.jpg "; System.Drawing.Image Image = System.Drawing.Image.FromFile (SourcePath); System.Drawing.Graphics Graphics = System.Drawing.Graphics.FromImage (image); Graphics. DrawImage (image, 0, 0, image. Width, image. Height); System.Drawing.Font Font = new System.Drawing.Font ("Verdana", 30); System.Drawing.Brush Brush = new System.Drawing.SolidBrush (System.Drawing.Color.White); String addtext = "Picture Add text watermark effect"; Graphics. DrawString (addtext, font, brush, 10, 10); Graphics. Dispose (); Resultimage.image = Image; //Picture Overall set transparency public void Makeimagewatermark () {String SourcePath = @ "... /.. /resources/test.jpg "; String Copypath = @ ". /.. /resources/image.jpg "; System.Drawing.Image Image = System.Drawing.Image.FromFile (SourcePath); SystEm. Drawing.image copyimage = System.Drawing.Image.FromFile (Copypath); Graphics g = graphics.fromimage (image); Transparency Setting Float alpha = 0.15f; The ImageAttributes object contains information about how bitmap and metafile colors are manipulated when rendering. ImageAttributes imageattributes = new ImageAttributes (); ColorMap: Defines the mapping of the conversion color colormap ColorMap = new ColorMap (); Here the watermark is defined as a picture with a green background color replaced with a transparent 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},//Red new float[] {0.0f, 1.0f, 0.0f, 0.0f , 0.0f},//green Green new float[] {0.0f, 0.0f, 1.0f, 0.0f, 0.0f},//blue blue new float[] {0.0f, 0.0f, 0.0f, Alpha, 0.0f},//Transparency New float[] {0.0f, 0.0f, 0.0f, 0.0f, 1.0f}}; ColorMatrix: Defines a 5 x 5 matrix containing RGBA space coordinates. Several methods of the ImageAttributes class adjust the image color by using a color matrix. ColorMatrix Wmcolormatrix = new ColorMatrix (colormatrixelements); Imageattributes.setcolormatriX (Wmcolormatrix, Colormatrixflag.default, Coloradjusttype.bitmap); 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, ImageAttributes); G.dispose (); Resultimage.image = Image; }