Beispiel #1
0
                public void ShouldCreateMagickImage()
                {
                    IMagickFactory factory = new MagickFactory();
                    var            data    = new byte[]
                    {
                        0, 0, 0, 0, 0, 0, 0, 0,
                        0, 0, 0, 0, 0, 0, 0, 0,
                        0, 0, 0, 0, 0, 0, 0, 0,
                        0, 0, 0, 0, 0, 0, 0xf0, 0x3f,
                        0, 0, 0, 0, 0, 0, 0, 0,
                        0, 0, 0, 0, 0, 0, 0xf0, 0x3f,
                        0, 0, 0, 0, 0, 0, 0, 0,
                        0, 0, 0, 0, 0, 0, 0, 0,
                    };

                    var settings = new PixelReadSettings(2, 1, StorageType.Double, PixelMapping.RGBA);

                    using (var stream = new MemoryStream(data))
                    {
                        using (IMagickImage image = factory.CreateImage(stream, settings))
                        {
                            Assert.IsInstanceOfType(image, typeof(MagickImage));
                            Assert.AreEqual(2, image.Width);
                        }
                    }
                }
 public void ShouldThrowExceptionWhenPixelReadSettingsIsNullAndFileNameIsSpecified()
 {
     ExceptionAssert.ThrowsArgumentNullException("settings", () =>
     {
         MagickFactory factory = new MagickFactory();
         factory.CreateImage(Files.CirclePNG, (PixelReadSettings)null);
     });
 }
Beispiel #3
0
 public void ShouldThrowExceptionWhenPixelStorageSettingsIsNullAndFileInfoIsSpecified()
 {
     ExceptionAssert.ThrowsArgumentNullException("pixelStorageSettings", () =>
     {
         MagickFactory factory = new MagickFactory();
         factory.CreateImage(new FileInfo(Files.CirclePNG), (PixelStorageSettings)null);
     });
 }
Beispiel #4
0
 public void ShouldThrowExceptionWhenPixelStorageSettingsIsNullAndByteArrayIsSpecified()
 {
     ExceptionAssert.ThrowsArgumentNullException("pixelStorageSettings", () =>
     {
         MagickFactory factory = new MagickFactory();
         factory.CreateImage(new byte[] { 215 }, (PixelStorageSettings)null);
     });
 }
Beispiel #5
0
                public void ShouldNotThrowExceptionWhenSettingsIsNull()
                {
                    IMagickFactory factory = new MagickFactory();

                    using (var image = factory.CreateImage(File.ReadAllBytes(Files.CirclePNG), (MagickReadSettings)null))
                    {
                    }
                }
 public void ShouldThrowExceptionWhenPixelReadSettingsIsNullAndStreamIsSpecified()
 {
     ExceptionAssert.ThrowsArgumentNullException("settings", () =>
     {
         MagickFactory factory = new MagickFactory();
         factory.CreateImage(new MemoryStream(new byte[] { 215 }), (PixelReadSettings)null);
     });
 }
Beispiel #7
0
                public void ShouldThrowExceptionWhenCountIsNegative()
                {
                    IMagickFactory factory = new MagickFactory();

                    ExceptionAssert.Throws <ArgumentException>("count", () =>
                    {
                        factory.CreateImage(new byte[] { 215 }, 0, -1);
                    });
                }
Beispiel #8
0
                public void ShouldThrowExceptionWhenSettingsIsNull()
                {
                    IMagickFactory factory = new MagickFactory();

                    ExceptionAssert.Throws <ArgumentNullException>("settings", () =>
                    {
                        factory.CreateImage(new FileInfo(Files.CirclePNG), (PixelReadSettings)null);
                    });
                }
Beispiel #9
0
                public void ShouldThrowExceptionWhenFileInfoIsNull()
                {
                    IMagickFactory factory = new MagickFactory();

                    ExceptionAssert.Throws <ArgumentNullException>("fileName", () =>
                    {
                        factory.CreateImage((string)null);
                    });
                }
Beispiel #10
0
                public void ShouldThrowExceptionWhenFileNameIsEmpty()
                {
                    IMagickFactory factory = new MagickFactory();

                    ExceptionAssert.Throws <ArgumentException>("fileName", () =>
                    {
                        factory.CreateImage(string.Empty);
                    });
                }
Beispiel #11
0
                public void ShouldThrowExceptionWhenArrayIsEmpty()
                {
                    IMagickFactory factory = new MagickFactory();

                    ExceptionAssert.Throws <ArgumentException>("data", () =>
                    {
                        factory.CreateImage(new byte[] { }, 0, 0);
                    });
                }
Beispiel #12
0
                public void ShouldThrowExceptionWhenStreamIsNull()
                {
                    IMagickFactory factory = new MagickFactory();

                    ExceptionAssert.Throws <ArgumentNullException>("stream", () =>
                    {
                        factory.CreateImage((Stream)null);
                    });
                }
Beispiel #13
0
                public void ShouldThrowExceptionWhenStreamIsEmpty()
                {
                    IMagickFactory factory = new MagickFactory();

                    ExceptionAssert.Throws <ArgumentException>("stream", () =>
                    {
                        factory.CreateImage(new MemoryStream());
                    });
                }
Beispiel #14
0
                public void ShouldThrowExceptionWhenArrayIsNull()
                {
                    IMagickFactory factory = new MagickFactory();

                    ExceptionAssert.Throws <ArgumentNullException>("data", () =>
                    {
                        factory.CreateImage((byte[])null, 0, 0);
                    });
                }
Beispiel #15
0
                public void ShouldNotThrowExceptionWhenSettingsIsNull()
                {
                    IMagickFactory factory = new MagickFactory();

                    using (IMagickImage image = factory.CreateImage(Files.CirclePNG, (MagickReadSettings)null))
                    {
                        Assert.IsInstanceOfType(image, typeof(MagickImage));
                    }
                }
Beispiel #16
0
                public void ShouldThrowExceptionWhenHeightIsNegative()
                {
                    IMagickFactory factory = new MagickFactory();

                    ExceptionAssert.Throws <ArgumentException>("height", () =>
                    {
                        factory.CreateImage("xc:red", 1, -1);
                    });
                }
Beispiel #17
0
                public void ShouldThrowExceptionWhenHeightIsZero()
                {
                    IMagickFactory factory = new MagickFactory();

                    ExceptionAssert.Throws <ArgumentException>("height", () =>
                    {
                        factory.CreateImage(MagickColors.Red, 1, 0);
                    });
                }
Beispiel #18
0
                public void ShouldThrowExceptionWhenWidthIsNegative()
                {
                    IMagickFactory factory = new MagickFactory();

                    ExceptionAssert.Throws <ArgumentException>("width", () =>
                    {
                        factory.CreateImage("xc:red", -1, 1);
                    });
                }
Beispiel #19
0
                public void ShouldThrowExceptionWhenWidthIsZero()
                {
                    IMagickFactory factory = new MagickFactory();

                    ExceptionAssert.Throws <ArgumentException>("width", () =>
                    {
                        factory.CreateImage(MagickColors.Red, 0, 1);
                    });
                }
Beispiel #20
0
                public void ShouldThrowExceptionWhenColorIsNull()
                {
                    IMagickFactory factory = new MagickFactory();

                    ExceptionAssert.Throws <ArgumentNullException>("color", () =>
                    {
                        factory.CreateImage((MagickColor)null, 1, 1);
                    });
                }
Beispiel #21
0
                public void ShouldThrowExceptionWhenFileNameIsNull()
                {
                    IMagickFactory factory  = new MagickFactory();
                    var            settings = new MagickReadSettings();

                    ExceptionAssert.Throws <ArgumentNullException>("fileName", () =>
                    {
                        factory.CreateImage((string)null, settings);
                    });
                }
Beispiel #22
0
                public void ShouldThrowExceptionWhenArrayIsEmpty()
                {
                    IMagickFactory factory  = new MagickFactory();
                    var            settings = new PixelReadSettings();

                    ExceptionAssert.Throws <ArgumentException>("data", () =>
                    {
                        factory.CreateImage(new byte[] { }, settings);
                    });
                }
        public void CreateImage_ReturnsMagickImage()
        {
            MagickFactory factory = new MagickFactory();

            using (IMagickImage image = factory.CreateImage())
            {
                Assert.IsInstanceOfType(image, typeof(MagickImage));
                Assert.AreEqual(0, image.Width);
            }
        }
Beispiel #24
0
                public void ShouldThrowExceptionWhenArrayIsNull()
                {
                    IMagickFactory factory  = new MagickFactory();
                    var            settings = new MagickReadSettings();

                    ExceptionAssert.Throws <ArgumentNullException>("data", () =>
                    {
                        factory.CreateImage(null, 0, 0, settings);
                    });
                }
Beispiel #25
0
                public void ShouldThrowExceptionWhenStreamIsNull()
                {
                    IMagickFactory factory  = new MagickFactory();
                    var            settings = new PixelReadSettings();

                    ExceptionAssert.Throws <ArgumentNullException>("stream", () =>
                    {
                        factory.CreateImage((Stream)null, settings);
                    });
                }
Beispiel #26
0
                public void ShouldThrowExceptionWhenSettingsIsNull()
                {
                    IMagickFactory factory = new MagickFactory();
                    var            bytes   = File.ReadAllBytes(Files.CirclePNG);

                    ExceptionAssert.Throws <ArgumentNullException>("settings", () =>
                    {
                        factory.CreateImage(bytes, 0, bytes.Length, (PixelReadSettings)null);
                    });
                }
Beispiel #27
0
            public void ShouldThrowExceptionWhenStreamIsEmptyAndPixelStorageSettingsIsSpecified()
            {
                ExceptionAssert.ThrowsArgumentException("stream", () =>
                {
                    var pixelStorageSettings = new PixelStorageSettings();

                    MagickFactory factory = new MagickFactory();
                    factory.CreateImage(new MemoryStream(), pixelStorageSettings);
                });
            }
Beispiel #28
0
                public void ShouldThrowExceptionWhenOffsetIsNegative()
                {
                    IMagickFactory factory  = new MagickFactory();
                    var            settings = new PixelReadSettings();

                    ExceptionAssert.Throws <ArgumentException>("offset", () =>
                    {
                        factory.CreateImage(new byte[] { 215 }, -1, 0, settings);
                    });
                }
        public void CreateImage_WithFileName_ReturnsMagickImage()
        {
            MagickFactory factory = new MagickFactory();

            using (IMagickImage image = factory.CreateImage(Files.ImageMagickJPG))
            {
                Assert.IsInstanceOfType(image, typeof(MagickImage));
                Assert.AreEqual(123, image.Width);
            }
        }
Beispiel #30
0
                public void ShouldThrowExceptionWhenCountIsZero()
                {
                    IMagickFactory factory  = new MagickFactory();
                    var            settings = new PixelReadSettings();

                    ExceptionAssert.Throws <ArgumentException>("count", () =>
                    {
                        factory.CreateImage(new byte[] { 215 }, 0, 0, settings);
                    });
                }