Class MagicWandTool

Class MagicWandTool

Numele spaţiului: Aspose.Imaging.MagicWand Asamblare: Aspose.Imaging.dll (25.4.0)

Clasa pentru magie wand algoritmul logica principală.

public class MagicWandTool : IPartialArgb32PixelLoader

Inheritance

object MagicWandTool

Implements

IPartialArgb32PixelLoader

Membrii moștenitori

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

Examples

Exemplul arată cum să alegeți o zonă simplă a unei imagini pe baza tonului și culorii oricărui pixel folosind instrumentul 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
                                                                                                                                    });
                                                                                                                                }

Exemplul arată cum să alegeți o zonă complicată a unei imagini folosind instrumentul Magic Wand și capacitatea de a interacționa cu măști (invert, union, substrate).

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(Călărașul, int[], Punctul, punctul)

Procesarea pixelelor încărcate.

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

Parameters

pixelsRectangle Rectangle

Pixelele sunt rectangle.

pixels int []

Pixele ARGB de 32 de bite.

start Point

Dacă nu este egal cu (left,top) înseamnă că nu este dreptunghiul complet pe care îl avem.

end Point

Dacă nu este egal cu (dreapta, jos) înseamnă că nu este un rectanglu complet pe care îl avem.

Select(Articole cu eticheta MagicWandSettings)

Creează un nou Aspose.Imaging.MagicWand.ImageMasks.ImagicBitMask bazat pe Wl17.MagicWorldSettings și sursa __ WL16__ .RasterIMage.

public static ImageBitMask Select(RasterImage source, MagicWandSettings settings)

Parameters

source RasterImage

Raster imagini pentru algoritmul de a lucra peste.

settings MagicWandSettings

Setări ale algoritmului magic wand utilizat în crearea mască.

Returns

ImageBitMask

Nou Aspose.Imaging.MagicWand.ImageMasks.ImagicBitMask.

 Română