本文整理汇总了C#中ImageMagick.MagickImage.Extent方法的典型用法代码示例。如果您正苦于以下问题:C# MagickImage.Extent方法的具体用法?C# MagickImage.Extent怎么用?C# MagickImage.Extent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageMagick.MagickImage
的用法示例。
在下文中一共展示了MagickImage.Extent方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test_BorderColor
public void Test_BorderColor()
{
using (MagickImage image = new MagickImage(MagickColors.MediumTurquoise, 10, 10))
{
ColorAssert.AreEqual(new MagickColor("#df"), image.Settings.BorderColor);
image.Settings.FillColor = MagickColors.Beige;
image.Settings.BorderColor = MagickColors.MediumTurquoise;
image.Extent(20, 20, Gravity.Center, MagickColors.Aqua);
image.Draw(new DrawableAlpha(0, 0, PaintMethod.FillToBorder));
ColorAssert.AreEqual(MagickColors.Beige, image, 0, 0);
ColorAssert.AreEqual(MagickColors.MediumTurquoise, image, 10, 10);
}
}
示例2: ExecuteExtent
private void ExecuteExtent(XmlElement element, MagickImage image)
{
Hashtable arguments = new Hashtable();
foreach (XmlAttribute attribute in element.Attributes)
{
if (attribute.Name == "backgroundColor")
arguments["backgroundColor"] = Variables.GetValue<MagickColor>(attribute);
else if (attribute.Name == "geometry")
arguments["geometry"] = Variables.GetValue<MagickGeometry>(attribute);
else if (attribute.Name == "gravity")
arguments["gravity"] = Variables.GetValue<Gravity>(attribute);
else if (attribute.Name == "height")
arguments["height"] = Variables.GetValue<Int32>(attribute);
else if (attribute.Name == "width")
arguments["width"] = Variables.GetValue<Int32>(attribute);
else if (attribute.Name == "x")
arguments["x"] = Variables.GetValue<Int32>(attribute);
else if (attribute.Name == "y")
arguments["y"] = Variables.GetValue<Int32>(attribute);
}
if (OnlyContains(arguments, "geometry"))
image.Extent((MagickGeometry)arguments["geometry"]);
else if (OnlyContains(arguments, "geometry", "backgroundColor"))
image.Extent((MagickGeometry)arguments["geometry"], (MagickColor)arguments["backgroundColor"]);
else if (OnlyContains(arguments, "geometry", "gravity"))
image.Extent((MagickGeometry)arguments["geometry"], (Gravity)arguments["gravity"]);
else if (OnlyContains(arguments, "geometry", "gravity", "backgroundColor"))
image.Extent((MagickGeometry)arguments["geometry"], (Gravity)arguments["gravity"], (MagickColor)arguments["backgroundColor"]);
else if (OnlyContains(arguments, "width", "height"))
image.Extent((Int32)arguments["width"], (Int32)arguments["height"]);
else if (OnlyContains(arguments, "width", "height", "backgroundColor"))
image.Extent((Int32)arguments["width"], (Int32)arguments["height"], (MagickColor)arguments["backgroundColor"]);
else if (OnlyContains(arguments, "width", "height", "gravity"))
image.Extent((Int32)arguments["width"], (Int32)arguments["height"], (Gravity)arguments["gravity"]);
else if (OnlyContains(arguments, "width", "height", "gravity", "backgroundColor"))
image.Extent((Int32)arguments["width"], (Int32)arguments["height"], (Gravity)arguments["gravity"], (MagickColor)arguments["backgroundColor"]);
else if (OnlyContains(arguments, "x", "y", "width", "height"))
image.Extent((Int32)arguments["x"], (Int32)arguments["y"], (Int32)arguments["width"], (Int32)arguments["height"]);
else
throw new ArgumentException("Invalid argument combination for 'extent', allowed combinations are: [geometry] [geometry, backgroundColor] [geometry, gravity] [geometry, gravity, backgroundColor] [width, height] [width, height, backgroundColor] [width, height, gravity] [width, height, gravity, backgroundColor] [x, y, width, height]");
}
示例3: Test_Extent
public void Test_Extent()
{
using (MagickImage image = new MagickImage())
{
image.Read(Files.RedPNG);
image.Resize(new MagickGeometry(100, 100));
Assert.AreEqual(100, image.Width);
Assert.AreEqual(33, image.Height);
image.BackgroundColor = MagickColor.Transparent;
image.Extent(100, 100, Gravity.Center);
Assert.AreEqual(100, image.Width);
Assert.AreEqual(100, image.Height);
Test_Pixel_Equal(image, 0, 0, MagickColor.Transparent);
}
}
示例4: Test_Composite_ChangeMask
public void Test_Composite_ChangeMask()
{
using (MagickImage background = new MagickImage("xc:red", 100, 100))
{
background.BackgroundColor = Color.White;
background.Extent(200, 100);
IDrawable[] drawables = new IDrawable[]
{
new DrawablePointSize(50),
new DrawableText(135, 70, "X")
};
using (MagickImage image = background.Clone())
{
image.Draw(drawables);
image.Composite(background, Gravity.Center, CompositeOperator.ChangeMask);
using (MagickImage result = new MagickImage(MagickColor.Transparent, 200, 100))
{
result.Draw(drawables);
Assert.AreEqual(0.073, result.Compare(image, ErrorMetric.RootMeanSquared), 0.001);
}
}
}
}
示例5: Test_Trim
public void Test_Trim()
{
using (MagickImage image = new MagickImage("xc:fuchsia", 50, 50))
{
ColorAssert.AreEqual(MagickColors.Fuchsia, image, 0, 0);
ColorAssert.AreEqual(MagickColors.Fuchsia, image, 49, 49);
image.Extent(100, 60, Gravity.Center, MagickColors.Gold);
Assert.AreEqual(100, image.Width);
Assert.AreEqual(60, image.Height);
ColorAssert.AreEqual(MagickColors.Gold, image, 0, 0);
ColorAssert.AreEqual(MagickColors.Fuchsia, image, 50, 30);
image.Trim();
Assert.AreEqual(50, image.Width);
Assert.AreEqual(50, image.Height);
ColorAssert.AreEqual(MagickColors.Fuchsia, image, 0, 0);
ColorAssert.AreEqual(MagickColors.Fuchsia, image, 49, 49);
}
}
示例6: Test_Extent
public void Test_Extent()
{
using (MagickImage image = new MagickImage())
{
image.Read(Files.RedPNG);
image.Resize(new MagickGeometry(100, 100));
Assert.AreEqual(100, image.Width);
Assert.AreEqual(33, image.Height);
image.BackgroundColor = MagickColors.Transparent;
image.Extent(100, 100, Gravity.Center);
Assert.AreEqual(100, image.Width);
Assert.AreEqual(100, image.Height);
ColorAssert.AreEqual(MagickColors.Transparent, image, 0, 0);
ColorAssert.AreEqual(MagickColors.Red, image, 15, 50);
ColorAssert.AreEqual(new MagickColor(0, 0, 0, 0), image, 35, 35);
}
}