예제 #1
0
            public void ShouldThrowExceptionWhenCollectionAlreadyContainsItem()
            {
                using (IMagickImageCollection images = new MagickImageCollection())
                {
                    var image = new MagickImage();
                    images.AddRange(new[] { image });

                    ExceptionAssert.Throws <InvalidOperationException>(() =>
                    {
                        images.AddRange(new[] { image });
                    });
                }
            }
        public void Test_Smush()
        {
            using (IMagickImageCollection collection = new MagickImageCollection())
            {
                ExceptionAssert.Throws <InvalidOperationException>(delegate()
                {
                    collection.SmushHorizontal(5);
                });

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

                collection.AddRange(Files.RoseSparkleGIF);

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

                using (IMagickImage image = collection.SmushVertical(40))
                {
                    Assert.AreEqual(70, image.Width);
                    Assert.AreEqual((46 * 3) + (40 * 2), image.Height);
                }
            }
        }
예제 #3
0
            public void ShouldNotThrowExceptionWhenFileNameReadSettingsIsNull()
            {
                using (IMagickImageCollection images = new MagickImageCollection())
                {
                    images.AddRange(Files.SnakewarePNG, null);

                    Assert.AreEqual(1, images.Count);
                }
            }
예제 #4
0
            public void ShouldNotThrowExceptionWhenCollectionIsEmpty()
            {
                using (IMagickImageCollection images = new MagickImageCollection())
                {
                    images.AddRange(new IMagickImage[] { });

                    Assert.AreEqual(0, images.Count);
                }
            }
예제 #5
0
            public void ShouldNotThrowExceptionWhenEnumerableImagesIsEmpty()
            {
                using (var images = new MagickImageCollection())
                {
                    images.AddRange(new IMagickImage <QuantumType> [0]);

                    Assert.Empty(images);
                }
            }
        public void Test_AddRange()
        {
            using (IMagickImageCollection 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 <IMagickImage> images = new List <IMagickImage>();
                images.Add(new MagickImage("xc:red", 100, 100));
                collection.AddRange(images);
                Assert.AreEqual(13, collection.Count);
            }
        }
예제 #7
0
            public void ShouldNotThrowExceptionWhenFileNameReadSettingsIsNull()
            {
                using (var images = new MagickImageCollection())
                {
                    images.AddRange(Files.SnakewarePNG, null);

                    Assert.Single(images);
                }
            }
예제 #8
0
            public void ShouldNotThrowExceptionWhenCollectionIsEmpty()
            {
                using (var images = new MagickImageCollection())
                {
                    images.AddRange(Array.Empty <IMagickImage <QuantumType> >());

                    Assert.Empty(images);
                }
            }
		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);
			}
		}
예제 #10
0
 public void ShouldThrowExceptionWhenFileNameIsNull()
 {
     ExceptionAssert.Throws <ArgumentNullException>("fileName", () =>
     {
         using (IMagickImageCollection images = new MagickImageCollection())
         {
             images.AddRange((string)null);
         }
     });
 }
예제 #11
0
 public void ShouldThrowExceptionWhenEnumerableImagesIsNull()
 {
     Assert.Throws <ArgumentNullException>("images", () =>
     {
         using (var images = new MagickImageCollection())
         {
             images.AddRange((IEnumerable <IMagickImage <QuantumType> >)null);
         }
     });
 }
예제 #12
0
 public void ShouldThrowExceptionWhenByteArrayIsEmpty()
 {
     Assert.Throws <ArgumentException>("data", () =>
     {
         using (var images = new MagickImageCollection())
         {
             images.AddRange(Array.Empty <byte>());
         }
     });
 }
예제 #13
0
 public void ShouldThrowExceptionWhenFileNameIsEmpty()
 {
     ExceptionAssert.ThrowsArgumentException("fileName", () =>
     {
         using (IMagickImageCollection images = new MagickImageCollection())
         {
             images.AddRange(string.Empty);
         }
     });
 }
예제 #14
0
 public void ShouldThrowExceptionWhenStreamIsNull()
 {
     ExceptionAssert.ThrowsArgumentNullException("stream", () =>
     {
         using (IMagickImageCollection images = new MagickImageCollection())
         {
             images.AddRange((Stream)null);
         }
     });
 }
예제 #15
0
 public void ShouldThrowExceptionWhenByteArrayIsNull()
 {
     ExceptionAssert.ThrowsArgumentNullException("data", () =>
     {
         using (IMagickImageCollection images = new MagickImageCollection())
         {
             images.AddRange((byte[])null);
         }
     });
 }
예제 #16
0
 public void ShouldThrowExceptionWhenEnumerableImagesIsNull()
 {
     ExceptionAssert.ThrowsArgumentNullException("images", () =>
     {
         using (IMagickImageCollection images = new MagickImageCollection())
         {
             images.AddRange((IEnumerable <IMagickImage>)null);
         }
     });
 }
예제 #17
0
            public void ShouldAddAllGifFrames()
            {
                using (IMagickImageCollection images = new MagickImageCollection(Files.RoseSparkleGIF))
                {
                    Assert.AreEqual(3, images.Count);

                    images.AddRange(Files.RoseSparkleGIF);
                    Assert.AreEqual(6, images.Count);
                }
            }
예제 #18
0
 public void ShouldThrowExceptionWhenImagesIsMagickImageCollection()
 {
     using (var images = new MagickImageCollection(Files.SnakewarePNG))
     {
         ExceptionAssert.ThrowsArgumentException("images", () =>
         {
             images.AddRange(images);
         });
     }
 }
예제 #19
0
 public void ShouldThrowExceptionWhenByteArrayIsEmpty()
 {
     ExceptionAssert.ThrowsArgumentException("data", () =>
     {
         using (IMagickImageCollection images = new MagickImageCollection())
         {
             images.AddRange(new byte[0]);
         }
     });
 }
예제 #20
0
 public void ShouldThrowExceptionWhenImagesContainsDuplicates()
 {
     using (IMagickImageCollection images = new MagickImageCollection())
     {
         ExceptionAssert.Throws <InvalidOperationException>(() =>
         {
             var image = new MagickImage();
             images.AddRange(new[] { image, image });
         });
     }
 }
예제 #21
0
            public void ShouldNotThrowExceptionWhenByteArrayReadSettingsIsNull()
            {
                var bytes = FileHelper.ReadAllBytes(Files.SnakewarePNG);

                using (var images = new MagickImageCollection())
                {
                    images.AddRange(bytes, null);

                    Assert.Single(images);
                }
            }
예제 #22
0
            public void ShouldNotThrowExceptionWhenByteArrayReadSettingsIsNull()
            {
                var bytes = File.ReadAllBytes(Files.SnakewarePNG);

                using (IMagickImageCollection images = new MagickImageCollection())
                {
                    images.AddRange(bytes, null);

                    Assert.AreEqual(1, images.Count);
                }
            }
예제 #23
0
            public void ShouldNotThrowExceptionWhenStreamReadSettingsIsNull()
            {
                using (IMagickImageCollection images = new MagickImageCollection())
                {
                    using (var stream = File.OpenRead(Files.SnakewarePNG))
                    {
                        images.AddRange(stream, null);

                        Assert.AreEqual(1, images.Count);
                    }
                }
            }
예제 #24
0
            public void ShouldNotThrowExceptionWhenStreamReadSettingsIsNull()
            {
                using (var images = new MagickImageCollection())
                {
                    using (var stream = File.OpenRead(Files.SnakewarePNG))
                    {
                        images.AddRange(stream, null);

                        EnumerableAssert.IsSingle(images);
                    }
                }
            }
예제 #25
0
        public void CreateGif(BitmapSource frame1, BitmapSource frame2)
        {
            var path     = Path.Combine(Path.GetTempPath(), "shadowclip");
            var filePath = Path.Combine(path, "shadowclip.gif");

            Directory.CreateDirectory(path);

            using (var collection = new MagickImageCollection())
            {
                collection.AddRange(ConvertToStream(frame1));
                collection[0].AnimationDelay = 50;

                collection.AddRange(ConvertToStream(frame2));
                collection[1].AnimationDelay = 50;

                collection.Optimize();

                collection.Write(filePath);
            }

            Process.Start("explorer.exe", $"/select, \"{filePath}\"");
        }
        public void Test_Combine_CMYK()
        {
            using (IMagickImage cmyk = new MagickImage(Files.CMYKJPG))
            {
                using (IMagickImageCollection collection = new MagickImageCollection())
                {
                    collection.AddRange(cmyk.Separate(Channels.CMYK));

                    Assert.AreEqual(4, collection.Count);

                    IMagickImage image = collection.Combine(ColorSpace.CMYK);
                    Assert.AreEqual(0.0, cmyk.Compare(image, ErrorMetric.RootMeanSquared));
                }
            }
        }
예제 #27
0
            public void ShouldNotCloneTheInputImages()
            {
                using (IMagickImageCollection images = new MagickImageCollection())
                {
                    var image = new MagickImage("xc:red", 100, 100);

                    var list = new List <IMagickImage> {
                        image
                    };

                    images.AddRange(list);

                    Assert.IsTrue(ReferenceEquals(image, list[0]));
                }
            }
예제 #28
0
            public void ShouldCombineCmykImage()
            {
                using (var cmyk = new MagickImage(Files.CMYKJPG))
                {
                    using (var collection = new MagickImageCollection())
                    {
                        collection.AddRange(cmyk.Separate(Channels.CMYK));

                        Assert.Equal(4, collection.Count);

                        using (var image = collection.Combine(ColorSpace.CMYK))
                        {
                            Assert.Equal(0.0, cmyk.Compare(image, ErrorMetric.RootMeanSquared));
                        }
                    }
                }
            }
예제 #29
0
            public void ShouldCombineSeparatedImages()
            {
                using (var rose = new MagickImage(Files.Builtin.Rose))
                {
                    using (var collection = new MagickImageCollection())
                    {
                        collection.AddRange(rose.Separate(Channels.RGB));

                        Assert.Equal(3, collection.Count);

                        using (var image = collection.Combine())
                        {
                            Assert.Equal(rose.TotalColors, image.TotalColors);
                        }
                    }
                }
            }
        public void Test_Morph()
        {
            using (IMagickImageCollection 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);
            }
        }
        public void Test_Morph()
        {
            using (var collection = new MagickImageCollection())
            {
                Assert.Throws <InvalidOperationException>(() =>
                {
                    collection.Morph(10);
                });

                collection.Add(Files.Builtin.Logo);

                Assert.Throws <InvalidOperationException>(() =>
                {
                    collection.Morph(10);
                });

                collection.AddRange(Files.Builtin.Wizard);

                collection.Morph(4);
                Assert.Equal(6, collection.Count);
            }
        }