Class MagicWandSettings

Class MagicWandSettings

Namespace: Aspose.Imaging.MagicWand
Assembly: Aspose.Imaging.dll (25.7.0)

A magic wand selection settings class.

public class MagicWandSettings
   {
       public string Color { get; set; }
       public int Size { get; set; }
       public bool Glowing { get; set; }
   }

Inheritance

object MagicWandSettings

Inherited Members

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 simple area of an image based on tone and color of any pixel using Magic Wand tool.

var imageFilePath = "input.png";
   using (RasterImage image = (RasterImage)Image.Load(imageFilePath))
   {
       MagicWandTool
           .Select(image, new MagicWandSettings(120, 100) { Threshold = 150 })
           .Apply();
       image.Save(outputFilePath, new ImageOptions.PngOptions()
       {
           ColorType = PngColorType.TruecolorWithAlpha
       });
   }

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

MagicWandSettings(Point)

Initializes a new instance of the Aspose.Imaging.MagicWand.MagicWandSettings class.

public MagicWandSettings(Point point)
   {
   }

Parameters

point Point

The reference point.

MagicWandSettings(int, int)

Initializes a new instance of the Aspose.Imaging.MagicWand.MagicWandSettings class.

public MagicWandSettings(int x, int y)
   {
   }

Parameters

x int

The x-coordinate of the reference point.

y int

The y-coordinate of the reference point.

Properties

AreaOfInterest

Gets or sets the bounds of the area for algorithm work.

public Rectangle AreaOfInterest
   {
      get;
      set;
   }

Property Value

Rectangle

ColorCompareMode

Gets or sets the algorithm how colors are compared.

public ColorComparisonMode ColorCompareMode
{
    get;
    set;
}

Property Value

ColorComparisonMode

ColorComparisonDelegate

Gets or sets the custom color comparison algorithm if Aspose.Imaging.MagicWand.MagicWandSettings.ColorCompareMode is set to Aspose.Imaging.MagicWand.ColorComparisonMode.Custom.

public MagicWandSettings.ColorComparison ColorComparisonDelegate
   {
      get;
      set;
   }

Property Value

MagicWandSettings . ColorComparison

ContiguousMode

Gets or sets a value indicating whether magic wand will define only contiguous pixels.

public bool ContiguousMode
{
    get;
    set;
}

Property Value

bool

DirectionalMode

Gets or sets the mode of flood fill search algorithm: four of eight direction search.

public FloodFillDirectionalMode DirectionalMode
   {
      get;
      set;
   }

Property Value

FloodFillDirectionalMode

Point

Gets or sets the reference point for algorithm work.

public Point Point
   {
      get;
   }

Property Value

Point

Threshold

Gets or sets the tolerance level for pixels color comparison.

public int Threshold
   {
      get;
      set;
   }

Property Value

int

 English