ContentAwareFillWatermarkOptions

Inheritance: java.lang.Object, com.aspose.imaging.watermark.options.WatermarkOptions

public class ContentAwareFillWatermarkOptions extends WatermarkOptions

The common Content Aware Fill Algorithm options.

Constructors

ConstructorDescription
ContentAwareFillWatermarkOptions(Point[] mask)Initializes a new instance of the ContentAwareFillWatermarkOptions class.
ContentAwareFillWatermarkOptions(GraphicsPath mask)Initializes a new instance of the ContentAwareFillWatermarkOptions class.

Methods

MethodDescription
getPatchSize()Gets the patch size (should be odd).
setPatchSize(byte value)Sets the patch size (should be odd).
getMaxPaintingAttempts()Gets the maximum number of painting attempts.
setMaxPaintingAttempts(int value)Sets the maximum number of painting attempts.
getInterestArea()Gets the area to take patches.
setInterestArea(Rectangle value)Sets the area to take patches.

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);
    }
}

ContentAwareFillWatermarkOptions(Point[] mask)

public ContentAwareFillWatermarkOptions(Point[] mask)

Initializes a new instance of the ContentAwareFillWatermarkOptions class.

Parameters:

ParameterTypeDescription
maskPoint[]The mask for the unknown area.

ContentAwareFillWatermarkOptions(GraphicsPath mask)

public ContentAwareFillWatermarkOptions(GraphicsPath mask)

Initializes a new instance of the ContentAwareFillWatermarkOptions class.

Parameters:

ParameterTypeDescription
maskGraphicsPathThe mask for the unknown area.

getPatchSize()

public final byte getPatchSize()

Gets the patch size (should be odd).

Value: The size of the patch.

Returns: byte - the patch size (should be odd).

setPatchSize(byte value)

public final void setPatchSize(byte value)

Sets the patch size (should be odd).

Value: The size of the patch.

Parameters:

ParameterTypeDescription
valuebytethe patch size (should be odd).

getMaxPaintingAttempts()

public final int getMaxPaintingAttempts()

Gets the maximum number of painting attempts. The algorithm will chose the best variant.

Value: The maximum number of painting attempts.

Returns: int - the maximum number of painting attempts.

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);
    }
}

setMaxPaintingAttempts(int value)

public final void setMaxPaintingAttempts(int value)

Sets the maximum number of painting attempts. The algorithm will chose the best variant.

Value: The maximum number of painting attempts.

Parameters:

ParameterTypeDescription
valueintthe maximum number of painting attempts.

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);
    }
}

getInterestArea()

public final Rectangle getInterestArea()

Gets the area to take patches.

Value: The area of interest to take patches.

Returns: Rectangle - the area to take patches.

setInterestArea(Rectangle value)

public final void setInterestArea(Rectangle value)

Sets the area to take patches.

Value: The area of interest to take patches.

Parameters:

ParameterTypeDescription
valueRectanglethe area to take patches.