WatermarkRemover
内容
[
隐藏
]Inheritance: java.lang.Object
public final class WatermarkRemover
用于操作水印的类。
方法
| 方法 | 描述 |
|---|---|
| paintOver(RasterImage source, WatermarkOptions options) | 从光栅图像中移除水印。 |
Example: The example shows how to remove any object from the image using Graphics Path with Content Aware fill algorithm.
String imageFilePath = "ball.png";
try (Image image = Image.load(imageFilePath))
{
PngImage pngImage = (PngImage)image;
GraphicsPath mask = new GraphicsPath();
Figure firstFigure = new Figure();
firstFigure.addShape(new EllipseShape(new RectangleF(350, 170, 570 - 350, 400 - 170)));
mask.addFigure(firstFigure);
ContentAwareFillWatermarkOptions options = new ContentAwareFillWatermarkOptions(mask);
options.setMaxPaintingAttempts(4);
try (Image result = WatermarkRemover.paintOver(pngImage, options))
{
result.Save(outputPath);
}
}
Example: The example shows how to remove any object from the image using Graphics Path with Telea algorithm.
String imageFilePath = "ball.png";
String outputPath = "no-watermark.png";
try (Image image = Image.load(imageFilePath))
{
PngImage pngImage = (PngImage) image;
GraphicsPath mask = new GraphicsPath();
Figure firstFigure = new Figure();
firstFigure.addShape(new EllipseShape(new RectangleF(350, 170, 570 - 350, 400 - 170)));
mask.addFigure(firstFigure);
TeleaWatermarkOptions options = new TeleaWatermarkOptions(mask);
try (RasterImage result = WatermarkRemover.paintOver(pngImage, options))
{
result.save(outputPath);
}
}
paintOver(RasterImage source, WatermarkOptions options)
public static RasterImage paintOver(RasterImage source, WatermarkOptions options)
从光栅图像中移除水印。
Parameters:
| 参数 | 类型 | 描述 |
|---|---|---|
| source | RasterImage | 源光栅图像。 |
| options | WatermarkOptions | 水印选项。 |
Returns: RasterImage - The resulting image.