Class MagicWandSettings
名称: Aspose.Imaging.MagicWand 收藏: Aspose.Imaging.dll (25.4.0)
A Magic Wand Selection Settings 班級。
public class MagicWandSettings
Inheritance
继承人
object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
Examples
示例显示如何选择一个简单的图像区域,基于任何像素的色调和颜色,使用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
});
}
示例显示如何使用 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 (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);
}
Constructors
MagicWandSettings(Point)
启动 Aspose.Imaging.MagicWand.MagicWandSettings 类的新例子。
public MagicWandSettings(Point point)
Parameters
point
Point
参考点。
MagicWandSettings(int , int , int)
启动 Aspose.Imaging.MagicWand.MagicWandSettings 类的新例子。
public MagicWandSettings(int x, int y)
Parameters
x
int
参考点的 x 协调。
y
int
参考点的 y 协调。
Properties
AreaOfInterest
接收或设置算法工作区域的界限。
public Rectangle AreaOfInterest { get; set; }
财产价值
ColorCompareMode
接收或设置算法如何比较颜色。
public ColorComparisonMode ColorCompareMode { get; set; }
财产价值
ColorComparisonDelegate
获取或设置自定义的颜色比较算法,如果 Aspose.Imaging.MagicWand.MagicWandSettings.ColorCompareMode 设置为 Aspose.Imaging.MagicWand.ColorComparisonMode.Custom。
public MagicWandSettings.ColorComparison ColorComparisonDelegate { get; set; }
财产价值
MagicWandSettings . ColorComparison
ContiguousMode
收到或设置一个值,表明魔法
public bool ContiguousMode { get; set; }
财产价值
DirectionalMode
接收或设置洪水模式填写搜索算法:四个八个方向搜索。
public FloodFillDirectionalMode DirectionalMode { get; set; }
财产价值
Point
获得或设置算法工作的参考点。
public Point Point { get; }
财产价值
Threshold
接收或设置对像素颜色比较的宽容水平。
public int Threshold { get; set; }