Beispiel #1
0
 private static EightBimValue Get8BimValue()
 {
     using (MagickImage image = new MagickImage(Files.FujiFilmFinePixS1ProJPG))
     {
         EightBimProfile profile = image.Get8BimProfile();
         return(profile.Values.First());
     }
 }
Beispiel #2
0
            public void ShouldReadProfileValues()
            {
                var bytes = ToBytes('8', 'B', 'I', 'M', (short)2000, (short)0, 1, (byte)0);

                var profile = new EightBimProfile(bytes);

                EnumerableAssert.IsSingle(profile.Values);
                EnumerableAssert.IsEmpty(profile.ClipPaths);
            }
Beispiel #3
0
            public void ShouldReadProfileValues()
            {
                var bytes = ToBytes('8', 'B', 'I', 'M', (short)2000, (short)0, 1, (byte)0);

                var profile = new EightBimProfile(bytes);

                Assert.AreEqual(1, profile.Values.Count());
                Assert.AreEqual(0, profile.ClipPaths.Count());
            }
        //===========================================================================================
        private static void TestProfileValues(EightBimProfile profile)
        {
            Assert.IsNotNull(profile);

            Assert.AreEqual(25, profile.Values.Count());

            foreach (EightBimValue value in profile.Values)
            {
                Assert.IsNotNull(value.ToByteArray());
            }
        }
Beispiel #5
0
            public void ShouldAllowInvalidValues()
            {
                var bytes = ToBytes('8', 'B', 'I', 'M', (short)42, (byte)0, 1);

                var profile = new EightBimProfile(bytes);

                EnumerableAssert.IsEmpty(profile.Values);

                bytes = ToBytes('8', 'B', 'I', 'M', (short)42, (short)0, -1);

                profile = new EightBimProfile(bytes);
                EnumerableAssert.IsEmpty(profile.Values);
            }
Beispiel #6
0
            public void ShouldReturnEmptyListWhenSizeIsUnknown()
            {
                using (IMagickImage image = new MagickImage(Files.EightBimTIF))
                {
                    var profile = image.Get8BimProfile();

                    profile = new EightBimProfile(profile.ToByteArray());

                    Assert.IsNotNull(profile);

                    Assert.AreEqual(0, profile.ClipPaths.Count());
                }
            }
Beispiel #7
0
            public void ShouldAllowInvalidValues()
            {
                var bytes = ToBytes('8', 'B', 'I', 'M', (short)42, (byte)0, 1);

                var profile = new EightBimProfile(bytes);

                Assert.AreEqual(0, profile.Values.Count());

                bytes = ToBytes('8', 'B', 'I', 'M', (short)42, (short)0, -1);

                profile = new EightBimProfile(bytes);
                Assert.AreEqual(0, profile.Values.Count());
            }
Beispiel #8
0
        public void Test_Values()
        {
            using (IMagickImage image = new MagickImage(Files.EightBimTIF))
            {
                EightBimProfile profile = image.Get8BimProfile();
                TestProfileValues(profile);

                using (IMagickImage emptyImage = new MagickImage(Files.ImageMagickJPG))
                {
                    Assert.IsNull(emptyImage.Get8BimProfile());
                    emptyImage.AddProfile(profile);

                    profile = emptyImage.Get8BimProfile();
                    TestProfileValues(profile);
                }
            }
        }
        //===========================================================================================
        private static void TestProfile(EightBimProfile profile)
        {
            Assert.IsNotNull(profile);

            Assert.AreEqual(2, profile.ClippingPaths.Count());

            IXPathNavigable first = profile.ClippingPaths.First();
            XDocument       doc   = XDocument.Load(first.CreateNavigator().ReadSubtree());

            Assert.AreEqual(@"<svg width=""200"" height=""200""><g><path fill=""#00000000"" stroke=""#00000000"" stroke-width=""0"" stroke-antialiasing=""false"" d=""M 45 58&#xA;L 80 124&#xA;L 147 147&#xA;L 45 147&#xA;L 45 58 Z&#xA;"" /></g></svg>", doc.ToString(SaveOptions.DisableFormatting));

            IXPathNavigable second = profile.ClippingPaths.Skip(1).First();

            doc = XDocument.Load(second.CreateNavigator().ReadSubtree());

            Assert.AreEqual(@"<svg width=""200"" height=""200""><g><path fill=""#00000000"" stroke=""#00000000"" stroke-width=""0"" stroke-antialiasing=""false"" d=""M 52 144&#xA;L 130 57&#xA;L 157 121&#xA;L 131 106&#xA;L 52 144 Z&#xA;"" /></g></svg>", doc.ToString(SaveOptions.DisableFormatting));
        }
Beispiel #10
0
        public void Test_ClippingPaths()
        {
            using (IMagickImage image = new MagickImage(Files.EightBimTIF))
            {
                EightBimProfile profile = image.Get8BimProfile();
                TestProfile(profile);

                using (IMagickImage emptyImage = new MagickImage(Files.EightBimTIF))
                {
                    emptyImage.Strip();
                    Assert.IsNull(emptyImage.GetIptcProfile());
                    emptyImage.AddProfile(profile);

                    profile = emptyImage.Get8BimProfile();
                    TestProfile(profile);
                }
            }
        }
Beispiel #11
0
        public void Test_CorruptProfile()
        {
            byte[] bytes = ToBytes('8', 'B', 'I', 'M', (short)42, (byte)0, 1);

            EightBimProfile profile = new EightBimProfile(bytes);

            Assert.AreEqual(0, profile.Values.Count());

            bytes = ToBytes('8', 'B', 'I', 'M', (short)42, (short)0, -1);

            profile = new EightBimProfile(bytes);
            Assert.AreEqual(0, profile.Values.Count());

            bytes = ToBytes('8', 'B', 'I', 'M', (short)2000, (short)0, 1, (byte)0);

            profile = new EightBimProfile(bytes);
            Assert.AreEqual(1, profile.Values.Count());
            Assert.AreEqual(0, profile.ClipPaths.Count());
        }
Beispiel #12
0
        private static void TestProfileValues(EightBimProfile profile)
        {
            Assert.IsNotNull(profile);

            Assert.AreEqual(25, profile.Values.Count());

            EightBimValue firstValue = profile.Values.First();

            Assert.AreEqual(1061, firstValue.ID);

            byte[] bytes = new byte[16] {
                154, 137, 173, 93, 40, 109, 186, 33, 2, 200, 203, 169, 103, 5, 63, 219
            };
            CollectionAssert.AreEqual(bytes, firstValue.ToByteArray());

            foreach (EightBimValue value in profile.Values)
            {
                Assert.IsNotNull(value.ToByteArray());
            }
        }
        public void Test_IEquatable()
        {
            using (MagickImage image = new MagickImage(Files.FujiFilmFinePixS1ProJPG))
            {
                ImageProfile first = image.GetExifProfile();

                Assert.IsFalse(first == null);
                Assert.IsFalse(first.Equals(null));
                Assert.IsTrue(first.Equals(first));
                Assert.IsTrue(first.Equals((object)first));

                ImageProfile second = image.GetExifProfile();
                Assert.IsNotNull(second);

                Assert.IsTrue(first == second);
                Assert.IsTrue(first.Equals(second));
                Assert.IsTrue(first.Equals((object)second));

                second = new EightBimProfile(new byte[] { 0 });

                Assert.IsTrue(first != second);
                Assert.IsFalse(first.Equals(second));
            }
        }