本文整理汇总了C#中ImageMagick.MagickImageCollection.OptimizePlus方法的典型用法代码示例。如果您正苦于以下问题:C# MagickImageCollection.OptimizePlus方法的具体用法?C# MagickImageCollection.OptimizePlus怎么用?C# MagickImageCollection.OptimizePlus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageMagick.MagickImageCollection
的用法示例。
在下文中一共展示了MagickImageCollection.OptimizePlus方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test_OptimizePlus
public void Test_OptimizePlus()
{
using (MagickImageCollection collection = new MagickImageCollection())
{
ExceptionAssert.Throws<InvalidOperationException>(delegate ()
{
collection.OptimizePlus();
});
collection.Add(new MagickImage(MagickColors.Red, 11, 11));
/* the second image will not be removed if it is a duplicate so we
need to add an extra one. */
collection.Add(new MagickImage(MagickColors.Red, 11, 11));
collection.Add(new MagickImage(MagickColors.Red, 11, 11));
MagickImage image = new MagickImage(MagickColors.Red, 11, 11);
using (var pixels = image.GetPixels())
{
pixels.Set(5, 5, new QuantumType[] { 0, Quantum.Max, 0 });
}
collection.Add(image);
collection.OptimizePlus();
Assert.AreEqual(3, collection.Count);
Assert.AreEqual(1, collection[1].Width);
Assert.AreEqual(1, collection[1].Height);
Assert.AreEqual(-1, collection[1].Page.X);
Assert.AreEqual(-1, collection[1].Page.Y);
ColorAssert.AreEqual(MagickColors.Red, collection[1], 0, 0);
Assert.AreEqual(1, collection[2].Width);
Assert.AreEqual(1, collection[2].Height);
Assert.AreEqual(5, collection[2].Page.X);
Assert.AreEqual(5, collection[2].Page.Y);
ColorAssert.AreEqual(MagickColors.Lime, collection[2], 0, 0);
}
}
示例2: ExecuteOptimizePlus
private static MagickImage ExecuteOptimizePlus(MagickImageCollection collection)
{
collection.OptimizePlus();
return null;
}