Class RectangleMask
Namespace: Aspose.Imaging.MagicWand.ImageMasks
Assembly: Aspose.Imaging.dll (25.7.0)
Describes a rectangle mask.
public class RectangleMask : ImageMask, IImageMask, ICloneable
{
}
Inheritance
object ← ImageMask ← RectangleMask
Implements
Inherited Members
ImageMask.Inflate(int) , ImageMask.Crop(Size) , ImageMask.Crop(int, int) , ImageMask.Crop(Rectangle) , ImageMask.IsOpaque(int, int) , ImageMask.IsTransparent(int, int) , ImageMask.GetByteOpacity(int, int) , ImageMask.Clone() , ImageMask.GetFeathered(FeatheringSettings) , ImageMask.Apply() , ImageMask.ApplyTo(RasterImage) , ImageMask.Invert() , ImageMask.Union(ImageMask) , ImageMask.Union(MagicWandSettings) , ImageMask.Union(RasterImage, MagicWandSettings) , ImageMask.Subtract(ImageMask) , ImageMask.Subtract(MagicWandSettings) , ImageMask.Subtract(RasterImage, MagicWandSettings) , ImageMask.Intersect(ImageMask) , ImageMask.Intersect(MagicWandSettings) , ImageMask.Intersect(RasterImage, MagicWandSettings) , ImageMask.ExclusiveDisjunction(ImageMask) , ImageMask.ExclusiveDisjunction(MagicWandSettings) , ImageMask.ExclusiveDisjunction(RasterImage, MagicWandSettings) , ImageMask.Source , ImageMask.Width , ImageMask.Height , ImageMask.Bounds , ImageMask.SelectionBounds , ImageMask.this[int, int] , object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
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).
var imageFilePath = "input.png";
using (RasterImage image = (RasterImage)Image.Load(imageFilePath))
{
image.MagicWandTool.Select(new MagicWandSettings(845, 128));
image.MagicWandTool.Union(new MagicWandSettings(416, 387));
image.MagicWandTool.Invert();
image.MagicWandTool.Subtract(new MagicWandSettings(1482, 346) { Threshold = 69 });
image.MagicWandTool.Subtract(new RectangleMask(0, 0, 800, 150));
image.MagicWandTool.Subtract(new RectangleMask(0, 380, 600, 220));
image.MagicWandTool.Subtract(new RectangleMask(930, 520, 110, 40));
image.MagicWandTool.Subtract(new RectangleMask(1370, 400, 120, 200));
image.MagicWandTool.GetFeathered(new FeatheringSettings() { Size = 3 });
image.MagicWandTool.Apply();
image.Save(outputFilePath);
}
Constructors
RectangleMask(int, int, int, int)
Initializes a new instance of the Aspose.Imaging.MagicWand.ImageMasks.RectangleMask class with the specified left-top point, width and height.
public RectangleMask(int x, int y, int width, int height)
{
}
Parameters
x
int
The x-coordinate of the left-top point of the selected area.
y
int
The y-coordinate of the left-top point of the selected area.
width
int
Width of the selected area.
height
int
Height of the selected area.
RectangleMask(Rectangle)
Initializes a new instance of the Aspose.Imaging.MagicWand.ImageMasks.RectangleMask class with the specified rectangle.
public Rectangle Mask(Rectangle selectedArea)
{
}
Parameters
selectedArea
Rectangle
Selected area specified as a rectangle.
Properties
SelectionBounds
Gets the bounds of the selected part of the mask, in pixels.
public override Rectangle SelectionBounds
{
get;
}
Property Value
this[int, int]
Gets the opacity of the specified pixel.
public override bool this[int x, int y]
{
get;
}
Property Value
Methods
Clone()
Creates a new object that is a copy of the current instance.
public override object Clone()
{
}
Returns
A new object that is a copy of this instance.
Crop(Rectangle)
Crops mask with the specified rectangle.
public override ImageMask Crop(Rectangle rectangle)
{
}
I've reformatted the given code to follow standard C# conventions, proper indentation, and spacing. The existing logic and functionality remain unchanged.
Parameters
rectangle
Rectangle
The specified rectangle.
Returns
A cropped RectangleMask as ImageMask.
Inflate(int)
Inflates this mask by the specified amount.
public override ImageMask Inflate(int size)
{
}
Since there's no actual code within the method, I have left it empty to preserve its current state. If there were any content in the implementation, it would be properly indented and spaced according to C# conventions.
Parameters
size
int
The amount to inflate this mask.
Returns
An inflated RectangleMask as ImageMask.