Class ImageMask
名称: Aspose.Imaging.MagicWand.ImageMasks 收藏: Aspose.Imaging.dll (25.4.0)
描述二进制图像面具。
public abstract class ImageMask : IImageMask, ICloneable
Inheritance
Derived
CircleMask , EmptyImageMask , ImageBitMask , RectangleMask
Implements
继承人
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 (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
ImageMask(int , int , int)
启动一个新的例子 Aspose.Imaging.MagicWand.ImageMasks.ImageMask 类与指定的宽度和高度。
protected ImageMask(int width, int height)
Parameters
width
int
面具的宽度。
height
int
面具的高度。
Properties
Bounds
接到这个面具的边界,在像素中。
public Rectangle Bounds { get; }
财产价值
Height
得到这个面具的高度,在像素。
public int Height { get; protected set; }
财产价值
SelectionBounds
接收面具所选择部分的边界,在像素中。
public abstract Rectangle SelectionBounds { get; }
财产价值
Source
获取源图像用于创建这个面具,如果存在。
public RasterImage Source { get; protected set; }
财产价值
Width
得到这个面具的宽度,在像素。
public int Width { get; protected set; }
财产价值
这个[int , int , int]
接收指定的像素的不透明度。
public abstract bool this[int x, int y] { get; }
财产价值
Methods
Apply()
应用当前面具到 Aspose.Imaging.RasterImage 来源,如果存在。
public void Apply()
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
});
}
Exceptions
当源图像未被定义时。
ApplyTo(RasterImage)
将当前面具应用到指定的 Aspose.Imaging.RasterImage。
public void ApplyTo(RasterImage image)
Parameters
image
RasterImage
使用面具的图像。
Exceptions
当图像不被定义时。
Clone()
创建一个新的对象,这是当前例子的副本。
public abstract object Clone()
Returns
一个新的对象,这是这个案例的副本。
Crop(Size)
按摩面具与指定的尺寸。
public ImageMask Crop(Size size)
Parameters
size
Size
指定的尺寸。
Returns
一张图像。
Crop(int , int , int)
切割面具与指定的宽度和高度。
public ImageMask Crop(int width, int height)
Parameters
width
int
具体的宽度。
height
int
指定的高度。
Returns
一张图像。
Crop(Rectangle)
面具用指定的直角。
public abstract ImageMask Crop(Rectangle rectangle)
Parameters
rectangle
Rectangle
指定的直角。
Returns
一张图像。
ExclusiveDisjunction(ImageMask)
获得现有面具的独家分离与提供。
public ImageBitMask ExclusiveDisjunction(ImageMask mask)
Parameters
mask
ImageMask
提供的面具
Returns
新 Aspose.Imaging.MagicWand.ImageMasks.ImageBitMask.
ExclusiveDisjunction(MagicWandSettings)
它获得了当前面具的独家分离,结果是对面具的来源应用的魔法窗帘选择。
public ImageBitMask ExclusiveDisjunction(MagicWandSettings settings)
Parameters
settings
MagicWandSettings
魔法风格设置。
Returns
新 Aspose.Imaging.MagicWand.ImageMasks.ImageBitMask.
Exceptions
当源图像未在面具中定义时。
ExclusiveDisjunction(首頁 〉外文書 〉文學 〉MagicWandSettings)
获得当前面具的独家分离,结果是对所提供的图像应用的魔法窗帘选择。
public ImageBitMask ExclusiveDisjunction(RasterImage image, MagicWandSettings settings)
Parameters
image
RasterImage
圖片來源:Magic Wand
settings
MagicWandSettings
魔法风格设置。
Returns
新 Aspose.Imaging.MagicWand.ImageMasks.ImageBitMask.
GetByteOpacity(int , int , int)
以比特准确度获得指定的像素的可透明度。
public byte GetByteOpacity(int x, int y)
Parameters
x
int
像素的X协调。
y
int
是 pixel 的 y 协调。
Returns
比特值,代表指定的像素的无效性。
GetFeathered(FeatheringSettings)
得到灰色面具与边界与指定的设置。
public ImageGrayscaleMask GetFeathered(FeatheringSettings settings = null)
Parameters
settings
FeatheringSettings
施加安排。
Returns
Aspose.Imaging.MagicWand.ImageMasks.ImageGrayscale 用封面边界按摩。
Inflate(因特)
把这个面具按所指定的数量注入。
public abstract ImageMask Inflate(int size)
Parameters
size
int
把这个面具投入多少钱。
Returns
一张图像。
Intersect(ImageMask)
接收现有面具的交叉与提供。
public ImageBitMask Intersect(ImageMask mask)
Parameters
mask
ImageMask
提供的面具
Returns
新 Aspose.Imaging.MagicWand.ImageMasks.ImageBitMask.
Intersect(MagicWandSettings)
接收当前面具的交叉,结果是对面具的来源应用的魔法窗帘选择。
public ImageBitMask Intersect(MagicWandSettings settings)
Parameters
settings
MagicWandSettings
魔法风格设置。
Returns
新 Aspose.Imaging.MagicWand.ImageMasks.ImageBitMask.
Exceptions
当源图像未在面具中定义时。
Intersect(首頁 〉外文書 〉文學 〉MagicWandSettings)
接收当前面具的交叉,结果是对所提供的图像应用的魔法窗帘选择。
public ImageBitMask Intersect(RasterImage image, MagicWandSettings settings)
Parameters
image
RasterImage
圖片來源:Magic Wand
settings
MagicWandSettings
魔法风格设置。
Returns
新 Aspose.Imaging.MagicWand.ImageMasks.ImageBitMask.
Invert()
接收当前面具的逆转。
public ImageBitMask Invert()
Returns
新 Aspose.Imaging.MagicWand.ImageMasks.ImageBitMask.
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 (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);
}
IsOpaque(int , int , int)
检查指定的像素是否模糊。
public bool IsOpaque(int x, int y)
Parameters
x
int
像素的X协调。
y
int
是 pixel 的 y 协调。
Returns
如果指定的像素是虚假的,否则是虚假的。
IsTransparent(int , int , int)
检查指定的像素是否透明。
public bool IsTransparent(int x, int y)
Parameters
x
int
像素的X协调。
y
int
是 pixel 的 y 协调。
Returns
如果指定的像素是透明的,否则是假的。
Subtract(ImageMask)
接收提供的面具从电流的分解。
public ImageBitMask Subtract(ImageMask mask)
Parameters
mask
ImageMask
提供的面具
Returns
新 Aspose.Imaging.MagicWand.ImageMasks.ImageBitMask.
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 (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);
}
Subtract(MagicWandSettings)
得到的结果的魔法窗帘选择应用到来源的当前面具从面具中提取。
public ImageBitMask Subtract(MagicWandSettings settings)
Parameters
settings
MagicWandSettings
魔法风格设置。
Returns
新 Aspose.Imaging.MagicWand.ImageMasks.ImageBitMask.
Exceptions
当源图像未在面具中定义时。
Subtract(首頁 〉外文書 〉文學 〉MagicWandSettings)
接收了从当前面具中提取的图像所应用的魔法窗帘选择的结果。
public ImageBitMask Subtract(RasterImage image, MagicWandSettings settings)
Parameters
image
RasterImage
圖片來源:Magic Wand
settings
MagicWandSettings
魔法风格设置。
Returns
新 Aspose.Imaging.MagicWand.ImageMasks.ImageBitMask.
Union(ImageMask)
接收现有面具与提供的联盟。
public ImageBitMask Union(ImageMask mask)
Parameters
mask
ImageMask
提供的面具
Returns
新 Aspose.Imaging.MagicWand.ImageMasks.ImageBitMask.
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 (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);
}
Union(MagicWandSettings)
接收现有面具的联盟,与面具的来源应用的魔法窗帘选择的结果。
public ImageBitMask Union(MagicWandSettings settings)
Parameters
settings
MagicWandSettings
魔法风格设置。
Returns
新 Aspose.Imaging.MagicWand.ImageMasks.ImageBitMask.
Exceptions
当源图像未在面具中定义时。
Union(首頁 〉外文書 〉文學 〉MagicWandSettings)
得到当前面具的联盟,与应用于所提供的图像的魔法窗帘选择的结果。
public ImageBitMask Union(RasterImage image, MagicWandSettings settings)
Parameters
image
RasterImage
圖片來源:Magic Wand
settings
MagicWandSettings
魔法风格设置。
Returns
新 Aspose.Imaging.MagicWand.ImageMasks.ImageBitMask.
Operators
运营商 +(ImageMask 和 ImageMask)
两个面具的联盟。
public static ImageBitMask operator +(ImageMask a, ImageMask b)
Parameters
第一面具
第二个面具
Returns
新 Aspose.Imaging.MagicWand.ImageMasks.ImageBitMask.
运营商(ImageMask 和 ImageMask)
单独排除两种面具。
public static ImageBitMask operator ^(ImageMask a, ImageMask b)
Parameters
第一面具
第二个面具
Returns
新 Aspose.Imaging.MagicWand.ImageMasks.ImageBitMask.
透明操作员 ImageGrayscaleMask(ImageMask)
Aspose.Imaging.MagicWand.ImageMasks.ImageGrayscaleMask 播放器。
public static explicit operator ImageGrayscaleMask(ImageMask mask)
Parameters
mask
ImageMask
面具的价值
Returns
新 Aspose.Imaging.MagicWand.ImageMasks.ImageGrayscaleMask
运营商 !(ImageMask)
换面具。
public static ImageBitMask operator !(ImageMask a)
Parameters
面具要逆转。
Returns
新 Aspose.Imaging.MagicWand.ImageMasks.ImageBitMask.
运营商 *(ImageMask 和 ImageMask)
两个面具的交叉。
public static ImageBitMask operator *(ImageMask a, ImageMask b)
Parameters
第一面具
第二个面具
Returns
新 Aspose.Imaging.MagicWand.ImageMasks.ImageBitMask.
运营商 -(ImageMask 和 ImageMask)
从第一面取出第二面具。
public static ImageBitMask operator -(ImageMask a, ImageMask b)
Parameters
第一面具
第二个面具
Returns
新 Aspose.Imaging.MagicWand.ImageMasks.ImageBitMask.