private static MagickImage ExecuteOptimizePlus(MagickImageCollection collection)
 {
   collection.OptimizePlus();
   return null;
 }
    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);
      }
    }
Esempio n. 3
0
 private static MagickImage ExecuteOptimizePlus(MagickImageCollection collection)
 {
     collection.OptimizePlus();
     return(null);
 }