/// <summary>
/// 除去指定区域水印
/// </summary>
/// <param name="sourceImagePath"></param>
/// <param name="outputImagePath"></param>
public static void RemoveWatermark(string sourceImagePath, string outputImagePath)
{
Rectangle watermarkRegion = new Rectangle(0, 0, 600, 200); // 根据需要调整这些值
Image originalImage = Image.FromFile(sourceImagePath);
using (var graphics = Graphics.FromImage(originalImage))
{
// 假设水印是不透明的,使用白色背景遮罩去除水印
using (Brush whiteBrush = new SolidBrush(Color.White))
{
graphics.FillRectangle(whiteBrush, watermarkRegion); // watermarkLocation 是一个 Rectangle 指定水印位置
}
// 保存去除水印后的图片
originalImage.Save(outputImagePath);
}
}