CSharp examples for System.Drawing.Imaging:Bitmap
add Watermark Image
using System.Drawing.Drawing2D; using System.Drawing.Imaging; using System.Drawing; using System.IO;/*ww w . j a v a2s . c o m*/ using System.Collections; using System; public class Main{ public static void addWatermarkImage(Graphics picture, string WaterMarkPicPath, string _watermarkPosition, int _width, int _height) { Image watermark = new Bitmap(WaterMarkPicPath); int xpos = 0; int ypos = 0; int w = watermark.Width; int h = watermark.Height; switch (_watermarkPosition) { case "WM_TOP_LEFT": xpos = 0 + 10; ypos = 0 + 10; break; case "WM_TOP_RIGHT": xpos = _width - w - 10; ypos = 0 + 10; break; case "WM_BOTTOM_RIGHT": xpos = _width - w - 10; ypos = _height - h - 10; break; case "WM_BOTTOM_LEFT": xpos = 0 + 10; ypos = _height - h - 10; break; case "WM_BOTTOM_MIDDLE": xpos = _width / 2 - w / 2; ypos = _height - h - 10; break; case "WM_TOP_MIDDLE": xpos = _width / 2 - w / 2; ypos = 0 + 10; break; } picture.DrawImage(watermark, xpos, ypos, w, h); watermark.Dispose(); } }