//加图片水印
System.Drawing.Image image = System.Drawing.Image.FromFile(path + picName);
System.Drawing.Image watermakeImage = System.Drawing.Image.FromFile(CopyPicpath);
Graphics g = Graphics.FromImage(image);
int x = 0; //x坐标
int y = 0; //y坐标
switch (position)
{
case "0": //左上
x = 0;
y = 0;
break;
case "1": //右上
x = image.Width - watermakeImage .Width;
y = 0;
break;
case "2": //左下
x = 0;
y = image.Height - watermakeImage .Height;
break;
case "3": //右下
x = image.Width - watermakeImage .Width;
y = image.Height - watermakeImage .Height;
break;
default:
break;
}
g.DrawImage(watermakeImage , new Rectangle(x, y, watermakeImage .Width, watermakeImage .Height), 0, 0, watermakeImage .Width, watermakeImage .Height, GraphicsUnit.Pixel);
g.Dispose();
//保存加水印过后的图片,删除原始图片
string newPath = path + "New_" + picName;
image.Save(newPath);
picNameWaterMack = "New_" + picName;
image.Dispose();
if (File.Exists(path + picName))
{
File.Delete(path + picName);
}