Class MagicWandTool

Class MagicWandTool

Le nom : Aspose.Imaging.MagicWand Assemblée: Aspose.Imaging.dll (25.4.0)

La classe pour la magie wand algorithme logique principale.

public class MagicWandTool : IPartialArgb32PixelLoader

Inheritance

object MagicWandTool

Implements

IPartialArgb32PixelLoader

I membri ereditari

object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()

Examples

L’exemple montre comment sélectionner une zone simple d’une image en fonction du ton et de la couleur de tout pixel en utilisant l’outil Magic Wand.

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 (120, 100) with custom threshold equal to 150
                                                                                                                                    MagicWandTool
                                                                                                                                        .Select(image, new MagicWandSettings(120, 100) { Threshold = 150 })
                                                                                                                                        // Apply mask to the image
                                                                                                                                        .Apply();

                                                                                                                                    // Save image with forced transparency color type option
                                                                                                                                    image.Save(outputFilePath, new ImageOptions.PngOptions()
                                                                                                                                    {
                                                                                                                                        ColorType = PngColorType.TruecolorWithAlpha
                                                                                                                                    });
                                                                                                                                }

L’exemple montre comment sélectionner une zone compliquée d’une image en utilisant l’outil Magic Wand et la capacité à interagir avec les masques (invert, union, substrat).

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

Methods

Process(Rectangle, int[ ], Le point, le point)

Traitement des pixels chargés.

public void Process(Rectangle pixelsRectangle, int[] pixels, Point start, Point end)

Parameters

pixelsRectangle Rectangle

I pixel sono rectangoli.

pixels int [ ]

I 32 bit di pixel ARGB.

start Point

Se non è uguale a (la sinistra, la parte superiore) significa che non è pieno rettangolo che abbiamo.

end Point

Se non uguale a (diretta, basso) significa che non è pieno rettangolo abbiamo.

Select(Mise à jour, MagicWandSettings)

Création d’un nouveau Aspose.Imaging.MagicWand.ImageMasks. ImageBitMask basé sur le Wl17.MAGICWAND. MAGIC WandSettings et la source de l’image.

public static ImageBitMask Select(RasterImage source, MagicWandSettings settings)

Parameters

source RasterImage

Raster image pour que l’algorithme fonctionne.

settings MagicWandSettings

Les paramètres de l’algorithme de wand magique utilisé dans la création de masques.

Returns

ImageBitMask

Nouveau Aspose.Imaging.MagicWand.ImageMasks. ImageBitMask.

 Français