コード例 #1
0
    public void Test_AddRange()
    {
      using (MagickImageCollection collection = new MagickImageCollection(Files.RoseSparkleGIF))
      {
        Assert.AreEqual(3, collection.Count);

        collection.AddRange(Files.RoseSparkleGIF);
        Assert.AreEqual(6, collection.Count);

        collection.AddRange(collection);
        Assert.AreEqual(12, collection.Count);

        List<MagickImage> images = new List<MagickImage>();
        images.Add(new MagickImage("xc:red", 100, 100));
        collection.AddRange(images);
        Assert.AreEqual(13, collection.Count);
      }
    }
コード例 #2
0
        ///<summary>
        /// Create a composite image by combining the images with the specified settings.
        ///</summary>
        ///<param name="settings">The settings to use.</param>
        ///<exception cref="MagickException"/>
        public MagickImage Montage(MontageSettings settings)
        {
            ThrowIfEmpty();

            Throw.IfNull("settings", settings);

            IntPtr images;

            try
            {
                AttachImages();
                if (!string.IsNullOrEmpty(settings.Label))
                {
                    _Images[0].Label = settings.Label;
                }
                images = _NativeInstance.Montage(_Images[0], settings);
            }
            finally
            {
                DetachImages();
            }

            using (MagickImageCollection collection = new MagickImageCollection())
            {
                collection.AddRange(MagickImage.CreateList(images, _Images[0].Settings));
                if (settings.TransparentColor != null)
                {
                    foreach (MagickImage image in collection)
                    {
                        image.Transparent(settings.TransparentColor);
                    }
                }

                return(collection.Merge());
            }
        }
コード例 #3
0
    public void Test_Smush()
    {
      using (MagickImageCollection collection = new MagickImageCollection())
      {
        ExceptionAssert.Throws<InvalidOperationException>(delegate ()
        {
          collection.SmushHorizontal(5);
        });

        ExceptionAssert.Throws<InvalidOperationException>(delegate ()
        {
          collection.SmushVertical(6);
        });

        collection.AddRange(Files.RoseSparkleGIF);

        using (MagickImage image = collection.SmushHorizontal(20))
        {
          Assert.AreEqual((70 * 3) + (20 * 2), image.Width);
          Assert.AreEqual(46, image.Height);
        }

        using (MagickImage image = collection.SmushVertical(40))
        {
          Assert.AreEqual(70, image.Width);
          Assert.AreEqual((46 * 3) + (40 * 2), image.Height);
        }
      }
    }
コード例 #4
0
    public void Test_Morph()
    {
      using (MagickImageCollection collection = new MagickImageCollection())
      {
        ExceptionAssert.Throws<InvalidOperationException>(delegate ()
        {
          collection.Morph(10);
        });

        collection.Add(Files.Builtin.Logo);

        ExceptionAssert.Throws<InvalidOperationException>(delegate ()
        {
          collection.Morph(10);
        });

        collection.AddRange(Files.Builtin.Wizard);

        collection.Morph(4);
        Assert.AreEqual(6, collection.Count);
      }
    }
コード例 #5
0
    public void Test_Combine()
    {
      using (MagickImage rose = new MagickImage(Files.Builtin.Rose))
      {
        using (MagickImageCollection collection = new MagickImageCollection())
        {
          ExceptionAssert.Throws<InvalidOperationException>(delegate ()
          {
            collection.Combine();
          });

          collection.AddRange(rose.Separate(Channels.RGB));

          Assert.AreEqual(3, collection.Count);

          MagickImage image = collection.Merge();
          Assert.AreNotEqual(rose.TotalColors, image.TotalColors);
          image.Dispose();

          image = collection.Combine();
          Assert.AreEqual(rose.TotalColors, image.TotalColors);
        }
      }
    }