Class RectangleMask
Contents
[
Hide
]RectangleMask class
Describes a rectangle mask.
public class RectangleMask : ImageMask
Constructors
Name | Description |
---|---|
RectangleMask(Rectangle) | Initializes a new instance of the RectangleMask class with the specified rectangle. |
RectangleMask(int, int, int, int) | Initializes a new instance of the RectangleMask class with the specified left-top point, width and height. |
Properties
Name | Description |
---|---|
Bounds { get; } | Gets the bounds, in pixels, of this mask. |
Height { get; } | Gets the height, in pixels, of this mask. |
override Item { get; } | Gets the opacity of the specified pixel. |
override SelectionBounds { get; } | Gets the bounds of the selected part of the mask, in pixels. |
Source { get; } | Gets the source image used to create this mask, if exists. |
Width { get; } | Gets the width, in pixels, of this mask. |
Methods
Name | Description |
---|---|
Apply() | Applies current mask to the RasterImage source, if exists. |
ApplyTo(RasterImage) | Applies current mask to the specified RasterImage . |
override Clone() | Creates a new object that is a copy of the current instance. |
override Crop(Rectangle) | Crops mask with the specified rectangle. |
Crop(Size) | Crops mask with the specified size. |
Crop(int, int) | Crops mask with the specified width and height. |
ExclusiveDisjunction(ImageMask) | Gets the exclusive disjunction of current mask with provided. |
ExclusiveDisjunction(MagicWandSettings) | Gets the exclusive disjunction of the current mask with the result of magic wand selection applied to the source of the mask. |
ExclusiveDisjunction(RasterImage, MagicWandSettings) | Gets the exclusive disjunction of the current mask with the result of magic wand selection applied to the provided image. |
GetByteOpacity(int, int) | Gets the opacity of the specified pixel with byte precision. |
GetFeathered(FeatheringSettings) | Gets grayscale mask with the border feathered with the specified settings. |
override Inflate(int) | Inflates this mask by the specified amount. |
Intersect(ImageMask) | Gets the intersection of current mask with provided. |
Intersect(MagicWandSettings) | Gets the intersection of the current mask with the result of magic wand selection applied to the source of the mask. |
Intersect(RasterImage, MagicWandSettings) | Gets the intersection of the current mask with the result of magic wand selection applied to the provided image. |
Invert() | Gets the inversion of the current mask. |
IsOpaque(int, int) | Checks if the specified pixel is opaque. |
IsTransparent(int, int) | Checks if the specified pixel is transparent. |
Subtract(ImageMask) | Gets the subtraction of the provided mask from current. |
Subtract(MagicWandSettings) | Gets the result of magic wand selection applied to the source of the current mask subtracted from the mask. |
Subtract(RasterImage, MagicWandSettings) | Gets the result of magic wand selection applied to the provided image subtracted from the current mask. |
Union(ImageMask) | Gets the union of the current mask with provided. |
Union(MagicWandSettings) | Gets the union of the current mask with the result of magic wand selection applied to the source of the mask. |
Union(RasterImage, MagicWandSettings) | Gets the union of the current mask with the result of magic wand selection applied to the provided image. |
Examples
The example shows how to select a complicated area of an image using Magic Wand tool and the ability to interact with masks (invert, union, substract).
[C#]
var imageFilePath = "input.png";
using (RasterImage image = (RasterImage)Image.Load(inputFilePath))
{
// Create a new mask using magic wand tool based on tone and color of pixel (845, 128)
MagicWandTool.Select(image, new MagicWandSettings(845, 128))
// Union the existing mask with the specified one created by magic wand tool
.Union(new MagicWandSettings(416, 387))
// Invert the existing mask
.Invert()
// Subtract the specified mask created by magic wand tool with specified threshold from the existing one
.Subtract(new MagicWandSettings(1482, 346) { Threshold = 69 })
// Subtract four specified rectangle masks from the existing mask one by one
.Subtract(new RectangleMask(0, 0, 800, 150))
.Subtract(new RectangleMask(0, 380, 600, 220))
.Subtract(new RectangleMask(930, 520, 110, 40))
.Subtract(new RectangleMask(1370, 400, 120, 200))
// Feather mask with specified settings
.GetFeathered(new FeatheringSettings() { Size = 3 })
// Apply mask to the image
.Apply();
// Save image
image.Save(outputFilePath);
}
See Also
- class ImageMask
- namespace Aspose.Imaging.MagicWand.ImageMasks
- assembly Aspose.Imaging