public void Test_TrimBounds()
        {
            using (IMagickImageCollection collection = new MagickImageCollection())
            {
                ExceptionAssert.Throws <InvalidOperationException>(() =>
                {
                    collection.TrimBounds();
                });

                collection.Add(Files.Builtin.Logo);
                collection.Add(Files.Builtin.Wizard);
                collection.TrimBounds();

                Assert.AreEqual(640, collection[0].Page.Width);
                Assert.AreEqual(640, collection[0].Page.Height);
                Assert.AreEqual(0, collection[0].Page.X);
                Assert.AreEqual(0, collection[0].Page.Y);

                Assert.AreEqual(640, collection[1].Page.Width);
                Assert.AreEqual(640, collection[1].Page.Height);
                Assert.AreEqual(0, collection[0].Page.X);
                Assert.AreEqual(0, collection[0].Page.Y);
            }
        }
        public void Test_Combine_sRGB()
        {
            using (IMagickImage rose = new MagickImage(Files.Builtin.Rose))
            {
                using (IMagickImageCollection collection = new MagickImageCollection())
                {
                    ExceptionAssert.Throws <InvalidOperationException>(() =>
                    {
                        collection.Combine();
                    });

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

                    Assert.AreEqual(3, collection.Count);

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

                    image = collection.Combine();
                    Assert.AreEqual(rose.TotalColors, image.TotalColors);
                }
            }
        }
Example #3
0
        public void Test_ColorCMYK()
        {
            ColorCMYK first = new ColorCMYK(0, 0, 0, 0);

            MagickColor second = new MagickColor("cmyk(0,0,0,0)");

            Assert.AreEqual(second, first.ToMagickColor());

            second = new MagickColor("#fff");
            Assert.AreNotEqual(second, first.ToMagickColor());

            second = new MagickColor("white");
            Assert.AreNotEqual(second, first.ToMagickColor());

            first = new ColorCMYK(0, 0, Quantum.Max, 0);

            second = new MagickColor("cmyk(0,0,100%,0)");
            Assert.AreEqual(second, first.ToMagickColor());

            first = new ColorCMYK(0, 0, Quantum.Max, 0, 0);

            second = new MagickColor("cmyka(0,0,100%,0,0)");
            Assert.AreEqual(second, first.ToMagickColor());

            first = new ColorCMYK((Percentage)0, (Percentage)100, (Percentage)0, (Percentage)100);
            Assert.AreEqual(0, first.C);
            Assert.AreEqual(Quantum.Max, first.M);
            Assert.AreEqual(0, first.Y);
            Assert.AreEqual(Quantum.Max, first.K);
            Assert.AreEqual(Quantum.Max, first.A);

            first = new ColorCMYK((Percentage)100, (Percentage)0, (Percentage)100, (Percentage)0, (Percentage)100);
            Assert.AreEqual(Quantum.Max, first.C);
            Assert.AreEqual(0, first.M);
            Assert.AreEqual(Quantum.Max, first.Y);
            Assert.AreEqual(0, first.K);
            Assert.AreEqual(Quantum.Max, first.A);

            first = new ColorCMYK("#0ff0");
            Assert.AreEqual(0, first.C);
            Assert.AreEqual(Quantum.Max, first.M);
            Assert.AreEqual(Quantum.Max, first.Y);
            Assert.AreEqual(0, first.K);
            Assert.AreEqual(Quantum.Max, first.A);

            first = new ColorCMYK("#ff00ff00");
            Assert.AreEqual(Quantum.Max, first.C);
            Assert.AreEqual(0, first.M);
            Assert.AreEqual(Quantum.Max, first.Y);
            Assert.AreEqual(0, first.K);
            Assert.AreEqual(Quantum.Max, first.A);

            first = new ColorCMYK("#0000ffff0000ffff");
            Assert.AreEqual(0, first.C);
            Assert.AreEqual(Quantum.Max, first.M);
            Assert.AreEqual(0, first.Y);
            Assert.AreEqual(Quantum.Max, first.K);
            Assert.AreEqual(Quantum.Max, first.A);

            ExceptionAssert.ThrowsArgumentException("color", () =>
            {
                new ColorCMYK("white");
            });

            ExceptionAssert.ThrowsArgumentException("color", () =>
            {
                new ColorCMYK("#ff00ff");
            });

            ExceptionAssert.ThrowsArgumentException("color", () =>
            {
                new ColorCMYK("#ffff0000fffff");
            });

            ExceptionAssert.ThrowsArgumentException("color", () =>
            {
                new ColorCMYK("#ffff0000fffff0000fffff");
            });

            ExceptionAssert.ThrowsArgumentException("color", () =>
            {
                new ColorCMYK("#fff");
            });
        }
Example #4
0
 public void ShouldThrowExceptionWhenFileNameIsEmpty()
 {
     ExceptionAssert.ThrowsArgumentException("fileName", () => MagickImageInfo.ReadCollection(string.Empty).ToArray());
 }
Example #5
0
        public void Test_Set()
        {
            using (IMagickImage image = new MagickImage(MagickColors.Red, 5, 10))
            {
                using (PixelCollection pixels = image.GetPixels())
                {
                    ExceptionAssert.Throws <ArgumentNullException>(delegate()
                    {
                        pixels.Set((QuantumType[])null);
                    });

                    ExceptionAssert.Throws <ArgumentNullException>(delegate()
                    {
                        pixels.Set((Pixel)null);
                    });

                    ExceptionAssert.Throws <ArgumentNullException>(delegate()
                    {
                        pixels.Set((Pixel[])null);
                    });

                    Assert.AreEqual(3, pixels.Channels);
                    Test_Set(pixels, new QuantumType[] { });
                    Test_Set(pixels, new QuantumType[] { 0 });
                    Test_Set(pixels, new QuantumType[] { 0, 0 });

                    pixels.Set(new QuantumType[] { 0, 0, 0 });
                    Test_PixelColor(pixels, MagickColors.Black);
                }

                using (PixelCollection pixels = image.GetPixels())
                {
                    Test_PixelColor(pixels, MagickColors.Black);
                }

                using (PixelCollection pixels = image.GetPixels())
                {
                    pixels.Set(new int[] { 100000, 0, 0 });
                    Test_PixelColor(pixels, MagickColors.Red);
                    pixels.Set(new byte[] { 0, 255, 0 });
                    Test_PixelColor(pixels, MagickColors.Lime);
                }

                using (PixelCollection pixels = image.GetPixels())
                {
                    pixels.SetArea(3, 3, 1, 1, new int[] { 100000, 0, 0 });
                    Test_PixelColor(pixels, 3, 3, MagickColors.Red);
                    pixels.SetArea(3, 3, 1, 1, new byte[] { 0, 255, 0 });
                    Test_PixelColor(pixels, 3, 3, MagickColors.Lime);
                }

                using (PixelCollection pixels = image.GetPixels())
                {
                    for (int x = 0; x < image.Width; x++)
                    {
                        for (int y = 0; y < image.Height; y++)
                        {
                            pixels.Set(x, y, new QuantumType[] { 0, 0, 0 });
                        }
                    }
                }
            }
        }
Example #6
0
        public void Test_SetValue()
        {
            double[] latitude = new double[] { 12.3, 4.56, 789.0 };

            using (MemoryStream memStream = new MemoryStream())
            {
                using (MagickImage image = new MagickImage(Files.FujiFilmFinePixS1ProJPG))
                {
                    ExifProfile profile = image.GetExifProfile();
                    profile.SetValue(ExifTag.Software, "Magick.NET");

                    ExifValue value = profile.GetValue(ExifTag.Software);
                    TestValue(value, "Magick.NET");

                    ExceptionAssert.Throws <ArgumentException>(delegate()
                    {
                        value.Value = 15;
                    });

                    profile.SetValue(ExifTag.ShutterSpeedValue, 75.55);

                    value = profile.GetValue(ExifTag.ShutterSpeedValue);
                    TestValue(value, 75.55);

                    ExceptionAssert.Throws <ArgumentException>(delegate()
                    {
                        value.Value = 75;
                    });

                    profile.SetValue(ExifTag.XResolution, 150.0);

                    value = profile.GetValue(ExifTag.XResolution);
                    TestValue(value, 150.0);

                    ExceptionAssert.Throws <ArgumentException>(delegate()
                    {
                        value.Value = "Magick.NET";
                    });

                    image.Density = new Density(72);

                    value = profile.GetValue(ExifTag.XResolution);
                    TestValue(value, 150.0);

                    value = profile.GetValue(ExifTag.ReferenceBlackWhite);
                    Assert.IsNotNull(value);

                    profile.SetValue(ExifTag.ReferenceBlackWhite, null);

                    value = profile.GetValue(ExifTag.ReferenceBlackWhite);
                    TestValue(value, (string)null);

                    profile.SetValue(ExifTag.GPSLatitude, latitude);

                    value = profile.GetValue(ExifTag.GPSLatitude);
                    TestValue(value, latitude);

                    image.AddProfile(profile);

                    image.Write(memStream);
                }

                memStream.Position = 0;
                using (MagickImage image = new MagickImage(memStream))
                {
                    ExifProfile profile = image.GetExifProfile();

                    Assert.IsNotNull(profile);
                    Assert.AreEqual(43, profile.Values.Count());

                    ExifValue value = profile.GetValue(ExifTag.Software);
                    TestValue(value, "Magick.NET");

                    value = profile.GetValue(ExifTag.ShutterSpeedValue);
                    TestValue(value, 75.55);

                    value = profile.GetValue(ExifTag.XResolution);
                    TestValue(value, 72.0);

                    value = profile.GetValue(ExifTag.ReferenceBlackWhite);
                    Assert.IsNull(value);

                    value = profile.GetValue(ExifTag.GPSLatitude);
                    TestValue(value, latitude);

                    profile.Parts = ExifParts.ExifTags;

                    image.AddProfile(profile);

                    memStream.Position = 0;
                    image.Write(memStream);
                }

                memStream.Position = 0;
                using (MagickImage image = new MagickImage(memStream))
                {
                    ExifProfile profile = image.GetExifProfile();

                    Assert.IsNotNull(profile);
                    Assert.AreEqual(24, profile.Values.Count());

                    Assert.IsNotNull(profile.GetValue(ExifTag.FNumber));
                    Assert.IsTrue(profile.RemoveValue(ExifTag.FNumber));
                    Assert.IsFalse(profile.RemoveValue(ExifTag.FNumber));
                    Assert.IsNull(profile.GetValue(ExifTag.FNumber));

                    Assert.AreEqual(23, profile.Values.Count());
                }
            }
        }
Example #7
0
            public void ShouldThrowExceptionWhenValueIsEmpty()
            {
                var factory = new MagickGeometryFactory();

                ExceptionAssert.Throws <ArgumentException>("value", () => factory.Create(string.Empty));
            }
Example #8
0
 public void ShouldThrowExceptionWhenDataIsNull()
 {
     ExceptionAssert.ThrowsArgumentNullException("data", () => MagickImageInfo.ReadCollection((byte[])null).ToArray());
 }
Example #9
0
 public void ShouldThrowExceptionWhenDataIsEmpty()
 {
     ExceptionAssert.ThrowsArgumentException("data", () => MagickImageInfo.ReadCollection(new byte[0]).ToArray());
 }
 public void ShouldThrowExceptionWhenStreamIsNull()
 {
     ExceptionAssert.Throws <ArgumentNullException>("stream", () => Optimizer.LosslessCompress((Stream)null));
 }
Example #11
0
        public void Test_Channel()
        {
            using (IMagickImage image = new MagickImage(Files.ImageMagickJPG))
            {
                PerceptualHash        phash   = image.PerceptualHash();
                ChannelPerceptualHash channel = phash.GetChannel(PixelChannel.Red);

                ExceptionAssert.Throws <ArgumentOutOfRangeException>(() =>
                {
                    channel.HclpHuPhash(7);
                });

                ExceptionAssert.Throws <ArgumentOutOfRangeException>(() =>
                {
                    channel.SrgbHuPhash(7);
                });

#if Q8
                TestChannel(channel, 0, 0.6980, 0.6980, 0.0974, 0.0993);
                TestChannel(channel, 1, 3.4388, 3.4390, 0.6582, 0.6685);
                TestChannel(channel, 2, 3.9123, 3.9123, 0.9238, 0.9195);
                TestChannel(channel, 3, 4.2922, 4.2920, 2.3627, 2.3354);
                TestChannel(channel, 4, 8.7570, 8.7574, 4.9574, 5.2273);
                TestChannel(channel, 5, 8.2422, 8.2149, 2.8422, 2.8360);
                TestChannel(channel, 6, 8.4397, 8.4394, 4.0087, 3.9636);
#elif Q16
                TestChannel(channel, 0, 0.6979, 0.6979, 0.2575, 0.2570);
                TestChannel(channel, 1, 3.4385, 3.4385, 1.0621, 1.0552);
                TestChannel(channel, 2, 3.9123, 3.9123, 1.3756, 1.3800);
                TestChannel(channel, 3, 4.2920, 4.2920, 2.8341, 2.8360);
                TestChannel(channel, 4, 8.7557, 8.7557, 5.1134, 5.1087);
                TestChannel(channel, 5, 8.3019, 8.3018, 3.4791, 3.4733);
                TestChannel(channel, 6, 8.4398, 8.4398, 5.0679, 5.0815);
#elif Q16HDRI
                TestChannel(channel, 0, 0.6979, 0.6979, 0.2944, 0.2945);
                TestChannel(channel, 1, 3.4385, 3.4385, 1.1850, 1.1834);
                TestChannel(channel, 2, 3.9123, 3.9123, 1.5006, 1.5009);
                TestChannel(channel, 3, 4.2920, 4.2920, 3.0480, 3.0419);
                TestChannel(channel, 4, 8.7557, 8.7557, 5.3844, 5.3651);
                TestChannel(channel, 5, 8.3018, 8.3018, 3.6804, 3.6675);
                TestChannel(channel, 6, 8.4398, 8.4398, 5.6247, 5.6501);
#else
#error Not implemented!
#endif

                channel = phash.GetChannel(PixelChannel.Green);
#if Q8
                TestChannel(channel, 0, 0.6942, 0.6942, -0.0601, -0.0601);
                TestChannel(channel, 1, 3.3993, 3.3995, 0.3090, 0.3093);
                TestChannel(channel, 2, 4.1171, 4.1172, 0.6084, 0.6083);
                TestChannel(channel, 3, 4.4847, 4.4847, 0.7559, 0.7566);
                TestChannel(channel, 4, 8.8180, 8.8183, 1.7224, 1.7237);
                TestChannel(channel, 5, 6.4829, 6.4832, 0.9413, 0.9421);
                TestChannel(channel, 6, 9.2143, 9.2141, 1.5065, 1.5074);
#elif Q16
                TestChannel(channel, 0, 0.6942, 0.6942, -0.0601, -0.0601);
                TestChannel(channel, 1, 3.3989, 3.3989, 0.3092, 0.3092);
                TestChannel(channel, 2, 4.1169, 4.1169, 0.6084, 0.6084);
                TestChannel(channel, 3, 4.4844, 4.4844, 0.7559, 0.7559);
                TestChannel(channel, 4, 8.8174, 8.8174, 1.7230, 1.7230);
                TestChannel(channel, 5, 6.4821, 6.4821, 0.9413, 0.9413);
                TestChannel(channel, 6, 9.2148, 9.2148, 1.5063, 1.5063);
#elif Q16HDRI
                TestChannel(channel, 0, 0.6942, 0.6942, -0.0601, -0.0601);
                TestChannel(channel, 1, 3.3989, 3.3989, 0.3092, 0.3092);
                TestChannel(channel, 2, 4.1169, 4.1169, 0.6084, 0.6084);
                TestChannel(channel, 3, 4.4844, 4.4844, 0.7559, 0.7559);
                TestChannel(channel, 4, 8.8174, 8.8174, 1.7230, 1.7230);
                TestChannel(channel, 5, 6.4821, 6.4821, 0.9413, 0.9413);
                TestChannel(channel, 6, 9.2148, 9.2148, 1.5063, 1.5063);
#else
#error Not implemented!
#endif

                channel = phash.GetChannel(PixelChannel.Blue);
#if Q8
                TestChannel(channel, 0, 0.7223, 0.7223, 0.6984, 0.6984);
                TestChannel(channel, 1, 3.8298, 3.8298, 3.4611, 3.4612);
                TestChannel(channel, 2, 5.1301, 5.1301, 4.1312, 4.1312);
                TestChannel(channel, 3, 5.0217, 5.0218, 4.4867, 4.4867);
                TestChannel(channel, 4, 10.4769, 10.4761, 8.8669, 8.8670);
                TestChannel(channel, 5, 6.9453, 6.9454, 6.6108, 6.6110);
                TestChannel(channel, 6, 10.1394, 10.1396, 9.0725, 9.0722);
#elif Q16
                TestChannel(channel, 0, 0.7222, 0.7222, 0.6984, 0.6984);
                TestChannel(channel, 1, 3.8295, 3.8295, 3.4609, 3.4609);
                TestChannel(channel, 2, 5.1304, 5.1304, 4.1314, 4.1314);
                TestChannel(channel, 3, 5.0214, 5.0214, 4.4866, 4.4866);
                TestChannel(channel, 4, 10.4771, 10.4772, 8.8663, 8.8663);
                TestChannel(channel, 5, 6.9448, 6.9448, 6.6094, 6.6094);
                TestChannel(channel, 6, 10.1388, 10.1388, 9.0737, 9.0737);
#elif Q16HDRI
                TestChannel(channel, 0, 0.7222, 0.7222, 0.6984, 0.6984);
                TestChannel(channel, 1, 3.8295, 3.8295, 3.4609, 3.4609);
                TestChannel(channel, 2, 5.1304, 5.1304, 4.1314, 4.1314);
                TestChannel(channel, 3, 5.0214, 5.0214, 4.4866, 4.4866);
                TestChannel(channel, 4, 10.4772, 10.4772, 8.8663, 8.8663);
                TestChannel(channel, 5, 6.9448, 6.9448, 6.6094, 6.6094);
                TestChannel(channel, 6, 10.1388, 10.1388, 9.0737, 9.0737);
#else
#error Not implemented!
#endif
            }
        }
 public void ShouldThrowExceptionWhenFileNameIsEmpty()
 {
     ExceptionAssert.Throws <ArgumentException>("fileName", () => Optimizer.LosslessCompress(string.Empty));
 }
 public void ShouldThrowExceptionWhenFileNameIsNull()
 {
     ExceptionAssert.Throws <ArgumentNullException>("fileName", () => Optimizer.LosslessCompress((string)null));
 }
Example #14
0
        public void Test_SetValue()
        {
            using (MemoryStream memStream = new MemoryStream())
            {
                string credit = null;
                for (int i = 0; i < 255; i++)
                {
                    credit += i.ToString() + ".";
                }

                using (IMagickImage image = new MagickImage(Files.FujiFilmFinePixS1ProJPG))
                {
                    IptcProfile profile = image.GetIptcProfile();
                    TestProfileValues(profile);

                    IptcValue value = profile.GetValue(IptcTag.Title);
                    TestValue(value, "Communications");

                    profile.SetValue(IptcTag.Title, "Magick.NET Title");
                    TestValue(value, "Magick.NET Title");

                    value = profile.GetValue(IptcTag.Title);
                    TestValue(value, "Magick.NET Title");

                    value = profile.Values.FirstOrDefault(val => val.Tag == IptcTag.ReferenceNumber);
                    Assert.IsNull(value);

                    profile.SetValue(IptcTag.ReferenceNumber, "Magick.NET ReferenceNümber");

                    value = profile.GetValue(IptcTag.ReferenceNumber);
                    TestValue(value, "Magick.NET ReferenceNümber");

                    profile.SetValue(IptcTag.Credit, credit);

                    value = profile.GetValue(IptcTag.Credit);
                    TestValue(value, credit);

                    // Remove the 8bim profile so we can overwrite the iptc profile.
                    image.RemoveProfile("8bim");
                    image.AddProfile(profile);

                    image.Write(memStream);
                    memStream.Position = 0;
                }

                using (IMagickImage image = new MagickImage(memStream))
                {
                    IptcProfile profile = image.GetIptcProfile();
                    TestProfileValues(profile, 19);

                    IptcValue value = profile.GetValue(IptcTag.Title);
                    TestValue(value, "Magick.NET Title");

                    value = profile.GetValue(IptcTag.ReferenceNumber);
                    TestValue(value, "Magick.NET ReferenceNümber");

                    value = profile.GetValue(IptcTag.Credit);
                    TestValue(value, credit);

                    ExceptionAssert.ThrowsArgumentNullException("encoding", () =>
                    {
                        profile.SetValue(IptcTag.Caption, null, "Test");
                    });

                    profile.SetValue(IptcTag.Caption, "Test");
                    value = profile.Values.ElementAt(1);
                    Assert.AreEqual("Test", value.Value);

                    profile.SetValue(IptcTag.Caption, Encoding.UTF32, "Test");
                    Assert.AreEqual(Encoding.UTF32, value.Encoding);
                    Assert.AreEqual("Test", value.Value);

                    Assert.IsTrue(profile.RemoveValue(IptcTag.Caption));
                    Assert.IsFalse(profile.RemoveValue(IptcTag.Caption));
                    Assert.IsNull(profile.GetValue(IptcTag.Caption));
                }
            }
        }
Example #15
0
        public void Test_Channel()
        {
            using (IMagickImage image = new MagickImage(Files.ImageMagickJPG))
            {
                PerceptualHash        phash   = image.PerceptualHash();
                ChannelPerceptualHash channel = phash.GetChannel(PixelChannel.Red);

                ExceptionAssert.Throws <ArgumentOutOfRangeException>(delegate()
                {
                    channel.HclpHuPhash(7);
                });

                ExceptionAssert.Throws <ArgumentOutOfRangeException>(delegate()
                {
                    channel.SrgbHuPhash(7);
                });

#if Q8
                TestChannel(channel, 0, 0.6980, 0.6980, 0.0959, 0.0993);
                TestChannel(channel, 1, 3.4390, 3.4390, 0.6548, 0.6673);
                TestChannel(channel, 2, 3.9123, 3.9123, 0.9158, 0.9181);
                TestChannel(channel, 3, 4.2921, 4.2920, 2.3586, 2.3443);
                TestChannel(channel, 4, 8.7567, 8.7573, 4.8847, 4.9039);
                TestChannel(channel, 5, 8.2505, 8.2147, 2.8316, 2.8253);
                TestChannel(channel, 6, 8.4397, 8.4394, 3.9994, 3.9786);
#elif Q16
                TestChannel(channel, 0, 0.6979, 0.6979, 0.2578, 0.2574);
                TestChannel(channel, 1, 3.4385, 3.4385, 1.0557, 1.0507);
                TestChannel(channel, 2, 3.9123, 3.9123, 1.3807, 1.3834);
                TestChannel(channel, 3, 4.2920, 4.2920, 2.8468, 2.8517);
                TestChannel(channel, 4, 8.7555, 8.7555, 5.2021, 5.1835);
                TestChannel(channel, 5, 8.2995, 8.2995, 3.5194, 3.5093);
                TestChannel(channel, 6, 8.4397, 8.4397, 5.0471, 5.0707);
#elif Q16HDRI
                TestChannel(channel, 0, 0.6979, 0.6979, 0.2928, 0.2932);
                TestChannel(channel, 1, 3.4385, 3.4385, 1.1752, 1.1743);
                TestChannel(channel, 2, 3.9123, 3.9123, 1.5002, 1.5016);
                TestChannel(channel, 3, 4.2920, 4.2920, 3.0739, 3.0682);
                TestChannel(channel, 4, 8.7556, 8.7555, 5.4484, 5.4357);
                TestChannel(channel, 5, 8.2997, 8.2994, 3.7144, 3.7052);
                TestChannel(channel, 6, 8.4398, 8.4397, 5.6010, 5.6031);
#else
#error Not implemented!
#endif

                channel = phash.GetChannel(PixelChannel.Green);
#if Q8
                TestChannel(channel, 0, 0.6942, 0.6942, -0.0601, -0.0601);
                TestChannel(channel, 1, 3.3992, 3.3994, 0.3088, 0.3090);
                TestChannel(channel, 2, 4.1171, 4.1171, 0.6081, 0.6081);
                TestChannel(channel, 3, 4.4847, 4.4847, 0.7557, 0.7561);
                TestChannel(channel, 4, 8.8179, 8.8181, 1.7217, 1.7225);
                TestChannel(channel, 5, 6.4828, 6.4830, 0.9410, 0.9414);
                TestChannel(channel, 6, 9.2143, 9.2141, 1.5061, 1.5066);
#elif Q16
                TestChannel(channel, 0, 0.6942, 0.6942, -0.0601, -0.0601);
                TestChannel(channel, 1, 3.3988, 3.3988, 0.3089, 0.3089);
                TestChannel(channel, 2, 4.1168, 4.1168, 0.6083, 0.6083);
                TestChannel(channel, 3, 4.4844, 4.4844, 0.7555, 0.7555);
                TestChannel(channel, 4, 8.8174, 8.8174, 1.7219, 1.7219);
                TestChannel(channel, 5, 6.4821, 6.4821, 0.9408, 0.9408);
                TestChannel(channel, 6, 9.2147, 9.2147, 1.5058, 1.5058);
#elif Q16HDRI
                TestChannel(channel, 0, 0.6942, 0.6942, -0.0601, -0.0601);
                TestChannel(channel, 1, 3.3988, 3.3988, 0.3089, 0.3089);
                TestChannel(channel, 2, 4.1168, 4.1168, 0.6083, 0.6083);
                TestChannel(channel, 3, 4.4844, 4.4844, 0.7555, 0.7555);
                TestChannel(channel, 4, 8.8174, 8.8174, 1.7219, 1.7219);
                TestChannel(channel, 5, 6.4821, 6.4821, 0.9408, 0.9408);
                TestChannel(channel, 6, 9.2148, 9.2147, 1.5058, 1.5058);
#else
#error Not implemented!
#endif

                channel = phash.GetChannel(PixelChannel.Blue);
#if Q8
                TestChannel(channel, 0, 0.7223, 0.7223, 0.6984, 0.6984);
                TestChannel(channel, 1, 3.8298, 3.8298, 3.4611, 3.4611);
                TestChannel(channel, 2, 5.1307, 5.1306, 4.1312, 4.1311);
                TestChannel(channel, 3, 5.0216, 5.0218, 4.4867, 4.4867);
                TestChannel(channel, 4, 10.4775, 10.4768, 8.8669, 8.8668);
                TestChannel(channel, 5, 6.9452, 6.9454, 6.6106, 6.6108);
                TestChannel(channel, 6, 10.1394, 10.1398, 9.0727, 9.0722);
#elif Q16
                TestChannel(channel, 0, 0.7222, 0.7222, 0.6984, 0.6984);
                TestChannel(channel, 1, 3.8295, 3.8295, 3.4608, 3.4608);
                TestChannel(channel, 2, 5.1309, 5.1309, 4.1314, 4.1314);
                TestChannel(channel, 3, 5.0213, 5.0213, 4.4866, 4.4866);
                TestChannel(channel, 4, 10.4778, 10.4778, 8.8663, 8.8663);
                TestChannel(channel, 5, 6.9448, 6.9448, 6.6093, 6.6093);
                TestChannel(channel, 6, 10.1388, 10.1388, 9.0737, 9.0737);
#elif Q16HDRI
                TestChannel(channel, 0, 0.7222, 0.7222, 0.6984, 0.6984);
                TestChannel(channel, 1, 3.8295, 3.8295, 3.4609, 3.4608);
                TestChannel(channel, 2, 5.1309, 5.1309, 4.1314, 4.1314);
                TestChannel(channel, 3, 5.0213, 5.0213, 4.4866, 4.4866);
                TestChannel(channel, 4, 10.4778, 10.4778, 8.8663, 8.8663);
                TestChannel(channel, 5, 6.9448, 6.9448, 6.6094, 6.6093);
                TestChannel(channel, 6, 10.1388, 10.1388, 9.0737, 9.0737);
#else
#error Not implemented!
#endif
            }
        }
Example #16
0
 public void ShouldThrowExceptionWhenStreamIsNull()
 {
     ExceptionAssert.ThrowsArgumentNullException("stream", () => MagickImageInfo.ReadCollection((Stream)null).ToArray());
 }
Example #17
0
        public void Test_Path_Exceptions()
        {
            ExceptionAssert.Throws <ArgumentException>(() =>
            {
                new PathArcAbs();
            });

            ExceptionAssert.Throws <ArgumentNullException>(() =>
            {
                new PathArcAbs(null);
            });

            ExceptionAssert.Throws <ArgumentException>(() =>
            {
                new PathArcAbs(new PathArc[] { });
            });

            ExceptionAssert.Throws <ArgumentNullException>(() =>
            {
                new PathArcAbs(new PathArc[] { null });
            });

            ExceptionAssert.Throws <ArgumentException>(() =>
            {
                new PathArcRel();
            });

            ExceptionAssert.Throws <ArgumentNullException>(() =>
            {
                new PathArcRel(null);
            });

            ExceptionAssert.Throws <ArgumentException>(() =>
            {
                new PathArcRel(new PathArc[] { });
            });

            ExceptionAssert.Throws <ArgumentNullException>(() =>
            {
                new PathArcRel(new PathArc[] { null });
            });

            ExceptionAssert.Throws <ArgumentException>(() =>
            {
                new PathLineToAbs();
            });

            ExceptionAssert.Throws <ArgumentNullException>(() =>
            {
                new PathLineToAbs(null);
            });

            ExceptionAssert.Throws <ArgumentException>(() =>
            {
                new PathLineToAbs(new PointD[] { });
            });

            ExceptionAssert.Throws <ArgumentException>(() =>
            {
                new PathLineToRel();
            });

            ExceptionAssert.Throws <ArgumentNullException>(() =>
            {
                new PathLineToRel(null);
            });

            ExceptionAssert.Throws <ArgumentException>(() =>
            {
                new PathLineToRel(new PointD[] { });
            });
        }
Example #18
0
 public void ShouldThrowExceptionWhenFileNameIsNull()
 {
     ExceptionAssert.ThrowsArgumentNullException("fileName", () => MagickImageInfo.ReadCollection((string)null).ToArray());
 }
Example #19
0
        public void Test_Constructor()
        {
            ExceptionAssert.ThrowsArgumentNullException("value", () =>
            {
                new MagickGeometry(null);
            });

            ExceptionAssert.ThrowsArgumentException("value", () =>
            {
                new MagickGeometry(string.Empty);
            });

            MagickGeometry geometry = new MagickGeometry("5x10!");

            Assert.AreEqual(0, geometry.X);
            Assert.AreEqual(0, geometry.Y);
            Assert.AreEqual(5, geometry.Width);
            Assert.AreEqual(10, geometry.Height);
            Assert.AreEqual(true, geometry.IgnoreAspectRatio);

            geometry = new MagickGeometry("10x5+2+1<");
            Assert.AreEqual(2, geometry.X);
            Assert.AreEqual(1, geometry.Y);
            Assert.AreEqual(10, geometry.Width);
            Assert.AreEqual(5, geometry.Height);
            Assert.AreEqual(true, geometry.Less);

            geometry = new MagickGeometry("5x10>");
            Assert.AreEqual(0, geometry.X);
            Assert.AreEqual(0, geometry.Y);
            Assert.AreEqual(5, geometry.Width);
            Assert.AreEqual(10, geometry.Height);
            Assert.AreEqual(true, geometry.Greater);

            geometry = new MagickGeometry("10x15^");
            Assert.AreEqual(0, geometry.X);
            Assert.AreEqual(0, geometry.Y);
            Assert.AreEqual(10, geometry.Width);
            Assert.AreEqual(15, geometry.Height);
            Assert.AreEqual(true, geometry.FillArea);

            geometry = new MagickGeometry("10@");
            Assert.AreEqual(0, geometry.X);
            Assert.AreEqual(0, geometry.Y);
            Assert.AreEqual(10, geometry.Width);
            Assert.AreEqual(0, geometry.Height);
            Assert.AreEqual(true, geometry.LimitPixels);

            geometry = new MagickGeometry("50%x0>");
            Assert.AreEqual(0, geometry.X);
            Assert.AreEqual(0, geometry.Y);
            Assert.AreEqual(50, geometry.Width);
            Assert.AreEqual(0, geometry.Height);
            Assert.AreEqual(true, geometry.IsPercentage);
            Assert.AreEqual(true, geometry.Greater);

            geometry = new MagickGeometry(5, 10);
            Assert.AreEqual(0, geometry.X);
            Assert.AreEqual(0, geometry.Y);
            Assert.AreEqual(5, geometry.Width);
            Assert.AreEqual(10, geometry.Height);

            geometry = new MagickGeometry(5, 10, 15, 20);
            Assert.AreEqual(5, geometry.X);
            Assert.AreEqual(10, geometry.Y);
            Assert.AreEqual(15, geometry.Width);
            Assert.AreEqual(20, geometry.Height);

            geometry = new MagickGeometry(new Percentage(50.0), new Percentage(10.0));
            Assert.AreEqual(0, geometry.X);
            Assert.AreEqual(0, geometry.Y);
            Assert.AreEqual(50, geometry.Width);
            Assert.AreEqual(10, geometry.Height);
            Assert.AreEqual(true, geometry.IsPercentage);

            geometry = new MagickGeometry(5, 10, (Percentage)15.0, (Percentage)20.0);
            Assert.AreEqual(5, geometry.X);
            Assert.AreEqual(10, geometry.Y);
            Assert.AreEqual(15, geometry.Width);
            Assert.AreEqual(20, geometry.Height);
            Assert.AreEqual(true, geometry.IsPercentage);
        }
Example #20
0
            public void ShouldThrowExceptionWhenValueIsNull()
            {
                var factory = new MagickGeometryFactory();

                ExceptionAssert.Throws <ArgumentNullException>("value", () => factory.Create(null));
            }