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); } } }
public void ShouldNotThrowExceptionWhenFileNameReadSettingsIsNull() { using (IMagickImageCollection images = new MagickImageCollection()) { images.AddRange(Files.SnakewarePNG, null); Assert.AreEqual(1, images.Count); } }
public void ShouldNotThrowExceptionWhenCollectionIsEmpty() { using (IMagickImageCollection images = new MagickImageCollection()) { images.AddRange(new IMagickImage[] { }); Assert.AreEqual(0, images.Count); } }
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); } }
public void ShouldNotThrowExceptionWhenFileNameReadSettingsIsNull() { using (var images = new MagickImageCollection()) { images.AddRange(Files.SnakewarePNG, null); Assert.Single(images); } }
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); } }
public void ShouldThrowExceptionWhenFileNameIsNull() { ExceptionAssert.Throws <ArgumentNullException>("fileName", () => { using (IMagickImageCollection images = new MagickImageCollection()) { images.AddRange((string)null); } }); }
public void ShouldThrowExceptionWhenEnumerableImagesIsNull() { Assert.Throws <ArgumentNullException>("images", () => { using (var images = new MagickImageCollection()) { images.AddRange((IEnumerable <IMagickImage <QuantumType> >)null); } }); }
public void ShouldThrowExceptionWhenByteArrayIsEmpty() { Assert.Throws <ArgumentException>("data", () => { using (var images = new MagickImageCollection()) { images.AddRange(Array.Empty <byte>()); } }); }
public void ShouldThrowExceptionWhenFileNameIsEmpty() { ExceptionAssert.ThrowsArgumentException("fileName", () => { using (IMagickImageCollection images = new MagickImageCollection()) { images.AddRange(string.Empty); } }); }
public void ShouldThrowExceptionWhenStreamIsNull() { ExceptionAssert.ThrowsArgumentNullException("stream", () => { using (IMagickImageCollection images = new MagickImageCollection()) { images.AddRange((Stream)null); } }); }
public void ShouldThrowExceptionWhenByteArrayIsNull() { ExceptionAssert.ThrowsArgumentNullException("data", () => { using (IMagickImageCollection images = new MagickImageCollection()) { images.AddRange((byte[])null); } }); }
public void ShouldThrowExceptionWhenEnumerableImagesIsNull() { ExceptionAssert.ThrowsArgumentNullException("images", () => { using (IMagickImageCollection images = new MagickImageCollection()) { images.AddRange((IEnumerable <IMagickImage>)null); } }); }
public void ShouldAddAllGifFrames() { using (IMagickImageCollection images = new MagickImageCollection(Files.RoseSparkleGIF)) { Assert.AreEqual(3, images.Count); images.AddRange(Files.RoseSparkleGIF); Assert.AreEqual(6, images.Count); } }
public void ShouldThrowExceptionWhenImagesIsMagickImageCollection() { using (var images = new MagickImageCollection(Files.SnakewarePNG)) { ExceptionAssert.ThrowsArgumentException("images", () => { images.AddRange(images); }); } }
public void ShouldThrowExceptionWhenByteArrayIsEmpty() { ExceptionAssert.ThrowsArgumentException("data", () => { using (IMagickImageCollection images = new MagickImageCollection()) { images.AddRange(new byte[0]); } }); }
public void ShouldThrowExceptionWhenImagesContainsDuplicates() { using (IMagickImageCollection images = new MagickImageCollection()) { ExceptionAssert.Throws <InvalidOperationException>(() => { var image = new MagickImage(); images.AddRange(new[] { image, image }); }); } }
public void ShouldNotThrowExceptionWhenByteArrayReadSettingsIsNull() { var bytes = FileHelper.ReadAllBytes(Files.SnakewarePNG); using (var images = new MagickImageCollection()) { images.AddRange(bytes, null); Assert.Single(images); } }
public void ShouldNotThrowExceptionWhenByteArrayReadSettingsIsNull() { var bytes = File.ReadAllBytes(Files.SnakewarePNG); using (IMagickImageCollection images = new MagickImageCollection()) { images.AddRange(bytes, null); Assert.AreEqual(1, images.Count); } }
public void ShouldNotThrowExceptionWhenStreamReadSettingsIsNull() { using (IMagickImageCollection images = new MagickImageCollection()) { using (var stream = File.OpenRead(Files.SnakewarePNG)) { images.AddRange(stream, null); Assert.AreEqual(1, images.Count); } } }
public void ShouldNotThrowExceptionWhenStreamReadSettingsIsNull() { using (var images = new MagickImageCollection()) { using (var stream = File.OpenRead(Files.SnakewarePNG)) { images.AddRange(stream, null); EnumerableAssert.IsSingle(images); } } }
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)); } } }
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])); } }
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)); } } } }
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); } }