Class MagicWandTool
Nom dels espais: Aspose.Imaging.MagicWand Assemblea: Aspose.Imaging.dll (25.4.0)
La classe per a l’algoritme de la màgia wand lògica principal.
public class MagicWandTool : IPartialArgb32PixelLoader
Inheritance
Implements
Membres heretats
object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
Examples
L’exemple mostra com triar una simple àrea d’una imatge basada en el to i el color de qualsevol píxel utilitzant l’eina 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 mostra com seleccionar una àrea complicada d’una imatge utilitzant l’eina Magic Wand i la capacitat per interactuar amb les màscares (invert, union, substrats).
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(El recte, int[]El punt, el punt)
Processar els píxels carregats.
public void Process(Rectangle pixelsRectangle, int[] pixels, Point start, Point end)
Parameters
pixelsRectangle
Rectangle
Els pixels són rectangles.
pixels
int
[]
Els píxels ARGB de 32 bit.
start
Point
Si no és igual a (esquerra, cap) vol dir que no està complet rectangle que tenim.
end
Point
Si no és igual a (dreta, baix) vol dir que no està complet rectangle que tenim.
Select(Descripció: MagicWandSettings)
Crea un nou Aspose.Imaging.MagicWand.ImageMasks.ImagicBitMask basat en Wl17.Settings i font de la pàgina web de l’enllaç.
public static ImageBitMask Select(RasterImage source, MagicWandSettings settings)
Parameters
source
RasterImage
Imatge raster per a l’algoritme per treballar.
settings
MagicWandSettings
Configuració de l’algoritme de la màgia que s’utilitza per crear una màscara.
Returns
Nou Aspose.Imaging.MagicWand.ImageMasks.ImagicBitMask.