本文整理汇总了C#中MagickImage.Resize方法的典型用法代码示例。如果您正苦于以下问题:C# MagickImage.Resize方法的具体用法?C# MagickImage.Resize怎么用?C# MagickImage.Resize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MagickImage
的用法示例。
在下文中一共展示了MagickImage.Resize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test_Resize
public void Test_Resize()
{
using (MagickImage image = new MagickImage())
{
image.Read(Files.GraphicsMagickNETIconPNG);
image.Resize(new MagickGeometry(64, 64));
Assert.AreEqual(64, image.Width);
Assert.AreEqual(64, image.Height);
image.Read(Files.GraphicsMagickNETIconPNG);
image.Resize(200);
Assert.AreEqual(256, image.Width);
Assert.AreEqual(256, image.Height);
image.Read(Files.GraphicsMagickNETIconPNG);
image.Resize(32, 32);
Assert.AreEqual(32, image.Width);
Assert.AreEqual(32, image.Height);
image.Read(Files.GraphicsMagickNETIconPNG);
image.Resize(new MagickGeometry("5x10!"));
Assert.AreEqual(5, image.Width);
Assert.AreEqual(10, image.Height);
image.Read(Files.GraphicsMagickNETIconPNG);
image.Resize(new MagickGeometry("32x32<"));
Assert.AreEqual(128, image.Width);
Assert.AreEqual(128, image.Height);
image.Read(Files.GraphicsMagickNETIconPNG);
image.Resize(new MagickGeometry("256x256<"));
Assert.AreEqual(256, image.Width);
Assert.AreEqual(256, image.Height);
image.Read(Files.GraphicsMagickNETIconPNG);
image.Resize(new MagickGeometry("32x32>"));
Assert.AreEqual(32, image.Width);
Assert.AreEqual(32, image.Height);
image.Read(Files.GraphicsMagickNETIconPNG);
image.Resize(new MagickGeometry("256x256>"));
Assert.AreEqual(128, image.Width);
Assert.AreEqual(128, image.Height);
Percentage percentage = new Percentage(-0.5);
ExceptionAssert.Throws<ArgumentException>(delegate()
{
image.Resize(percentage);
});
}
}
示例2: 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);
using (PixelCollection pixels = image.GetReadOnlyPixels())
{
Assert.IsTrue(pixels.GetPixel(0, 0).ToColor() == MagickColor.Transparent);
}
}
}