Beispiel #1
0
        public void ConstructorTest()
        {
            // Arrange
            int type = 4;

            double[] parameters   = new double[] { 2.4, 1.0 / 1.055, 0.055 / 1.055, 1.0 / 12.92, 0.04045 };
            double   gamma        = 2.2;
            uint     nItems       = 0;
            string   languageCode = "en";
            string   countryCode  = "US";
            string   text         = "constructor";

            using (var expectedUcr = ToneCurve.BuildParametric(null, type, parameters))
                using (var expectedBg = ToneCurve.BuildGamma(null, gamma))
                    using (var expectedDesc = MultiLocalizedUnicode.Create(null, nItems))
                    {
                        expectedDesc.SetASCII(languageCode, countryCode, text);

                        // Act
                        var target     = new UcrBg(expectedUcr, expectedBg, expectedDesc);
                        var actualUcr  = target.Ucr;
                        var actualBg   = target.Bg;
                        var actualDesc = target.Desc;

                        // Assert
                        Assert.AreSame(expectedUcr, actualUcr);
                        Assert.AreSame(expectedBg, actualBg);
                        Assert.AreSame(expectedDesc, actualDesc);
                    }
        }
Beispiel #2
0
        public void ConstructorTest()
        {
            // Arrange
            int type = 4;

            double[] parameters   = new double[] { 2.4, 1.0 / 1.055, 0.055 / 1.055, 1.0 / 12.92, 0.04045 };
            double   gamma        = 2.2;
            uint     nItems       = 0;
            string   languageCode = "en";
            string   countryCode  = "US";
            string   text         = "constructor";

            using (var context = Context.Create(IntPtr.Zero, IntPtr.Zero))
                using (var ucr = ToneCurve.BuildParametric(context, type, parameters))
                    using (var bg = ToneCurve.BuildGamma(context, gamma))
                        using (var desc = MultiLocalizedUnicode.Create(context, nItems))
                        {
                            desc.SetASCII(languageCode, countryCode, text);

                            var expectedUcr  = ucr.Handle;
                            var expectedBg   = bg.Handle;
                            var expectedDesc = desc.Handle;

                            // Act
                            var target     = new UcrBg(ucr, bg, desc);
                            var actualUcr  = target.Ucr;
                            var actualBg   = target.Bg;
                            var actualDesc = target.Desc;

                            // Assert
                            Assert.AreEqual(expectedUcr, actualUcr);
                            Assert.AreEqual(expectedBg, actualBg);
                            Assert.AreEqual(expectedDesc, actualDesc);
                        }
        }
Beispiel #3
0
        public void ReadTagTest()
        {
            // Arrange
            double gammaUcr = 2.4, gammaBg = -2.2;
            string languageCode = "en";
            string countryCode  = "US";
            string expectedText = "read-tag";

            using (var ucr = ToneCurve.BuildGamma(null, gammaUcr))
                using (var bg = ToneCurve.BuildGamma(null, gammaBg))
                    using (var desc = MultiLocalizedUnicode.Create(null))
                    {
                        desc.SetASCII(languageCode, countryCode, expectedText);

                        var target = new UcrBg(ucr, bg, desc);
                        using (var profile = Profile.CreatePlaceholder(null))
                        {
                            profile.WriteTag(TagSignature.UcrBg, target);

                            // Act
                            var actual     = profile.ReadTag <UcrBg>(TagSignature.UcrBg);
                            var actualUcr  = actual.Ucr;
                            var actualBg   = actual.Bg;
                            var actualDesc = actual.Desc;

                            // Assert
                            Assert.IsNotNull(actualUcr);
                            Assert.IsNotNull(actualBg);
                            Assert.IsNotNull(actualDesc);
                            var actualText = actualDesc.GetASCII(languageCode, countryCode);
                            Assert.AreEqual(expectedText, actualText);
                        }
                    }
        }
Beispiel #4
0
        public void BuildGammaTest()
        {
            // Arrange
            IntPtr plugin   = IntPtr.Zero;
            IntPtr userData = IntPtr.Zero;
            double gamma    = 2.2;

            // Act
            using (var context = Context.Create(plugin, userData))
                using (var toneCurve = ToneCurve.BuildGamma(context, gamma))
                {
                    // Assert
                    Assert.IsNotNull(toneCurve);
                }
        }
Beispiel #5
0
        public void ReverseTest2()
        {
            // Arrange
            IntPtr plugin   = IntPtr.Zero;
            IntPtr userData = IntPtr.Zero;
            double gamma    = 2.2;

            // Act
            using (var context = Context.Create(plugin, userData))
                using (var toneCurve = ToneCurve.BuildGamma(context, gamma))
                    using (var duplicate = toneCurve.Reverse(4096))
                    {
                        // Assert
                        Assert.IsNotNull(duplicate);
                    }
        }
Beispiel #6
0
        public void IsDescendingTest()
        {
            // Arrange
            IntPtr plugin   = IntPtr.Zero;
            IntPtr userData = IntPtr.Zero;
            double gamma    = 2.2;

            // Act
            using (var context = Context.Create(plugin, userData))
                using (var toneCurve = ToneCurve.BuildGamma(context, gamma))
                {
                    var isDescending = toneCurve.IsDescending;

                    // Assert
                    Assert.IsFalse(isDescending);
                }
        }
Beispiel #7
0
        public void IsMonotonicTest()
        {
            // Arrange
            IntPtr plugin   = IntPtr.Zero;
            IntPtr userData = IntPtr.Zero;
            double gamma    = 2.2;

            // Act
            using (var context = Context.Create(plugin, userData))
                using (var toneCurve = ToneCurve.BuildGamma(context, gamma))
                {
                    var isMonotonic = toneCurve.IsMonotonic;

                    // Assert
                    Assert.IsTrue(isMonotonic);
                }
        }
Beispiel #8
0
        public void JoinTest()
        {
            // Arrange
            IntPtr plugin   = IntPtr.Zero;
            IntPtr userData = IntPtr.Zero;
            double gamma    = 3.0;

            // Act
            using (var context = Context.Create(plugin, userData))
                using (var forward = ToneCurve.BuildGamma(context, gamma))
                    using (var reverse = ToneCurve.BuildGamma(context, gamma))
                        using (var joined = forward.Join(context, reverse, 256))
                        {
                            // Assert
                            Assert.IsNotNull(joined);
                        }
        }
Beispiel #9
0
        public void FromHandleTest()
        {
            // Arrange
            int type = 4;

            double[] parameters   = new double[] { 2.4, 1.0 / 1.055, 0.055 / 1.055, 1.0 / 12.92, 0.04045 };
            double   gamma        = 2.2;
            uint     nItems       = 0;
            string   languageCode = "en";
            string   countryCode  = "US";
            string   expectedText = "from-handle";

            using (var context = Context.Create(IntPtr.Zero, IntPtr.Zero))
                using (var ucr = ToneCurve.BuildParametric(context, type, parameters))
                    using (var bg = ToneCurve.BuildGamma(context, gamma))
                        using (var desc = MultiLocalizedUnicode.Create(context, nItems))
                        {
                            desc.SetASCII(languageCode, countryCode, expectedText);

                            var notExpectedUcr  = IntPtr.Zero;
                            var notExpectedBg   = IntPtr.Zero;
                            var notExpectedDesc = IntPtr.Zero;

                            var target = new UcrBg(ucr, bg, desc);

                            using (var profile = Profile.CreatePlaceholder(null))
                            {
                                profile.WriteTag(TagSignature.UcrBg, target);
                                IntPtr handle = profile.ReadTag(TagSignature.UcrBg);

                                // Act
                                var actual     = UcrBg.FromHandle(handle);
                                var actualUcr  = actual.Ucr;
                                var actualBg   = actual.Bg;
                                var actualDesc = actual.Desc;

                                // Assert
                                Assert.AreNotEqual(notExpectedUcr, actualUcr);
                                Assert.AreNotEqual(notExpectedBg, actualBg);
                                Assert.AreNotEqual(notExpectedDesc, actualDesc);
                                var desc2      = MultiLocalizedUnicode.FromHandle(actualDesc);
                                var actualText = desc2.GetASCII(languageCode, countryCode);
                                Assert.AreEqual(expectedText, actualText);
                            }
                        }
        }
Beispiel #10
0
        public void EstimatedTableTest()
        {
            // Arrange
            IntPtr plugin      = IntPtr.Zero;
            IntPtr userData    = IntPtr.Zero;
            double gamma       = 2.2;
            IntPtr notExpected = IntPtr.Zero;

            // Act
            using (var context = Context.Create(plugin, userData))
                using (var toneCurve = ToneCurve.BuildGamma(context, gamma))
                {
                    IntPtr actual = toneCurve.EstimatedTable;

                    // Assert
                    Assert.AreNotEqual(notExpected, actual);
                }
        }
Beispiel #11
0
        public void EstimateGammaTest()
        {
            // Arrange
            IntPtr plugin    = IntPtr.Zero;
            IntPtr userData  = IntPtr.Zero;
            double expected  = 2.2;
            double precision = 0.01;

            // Act
            using (var context = Context.Create(plugin, userData))
                using (var toneCurve = ToneCurve.BuildGamma(context, expected))
                {
                    var actual = toneCurve.EstimateGamma(precision);

                    // Assert
                    Assert.AreEqual(expected, actual, precision);
                }
        }
Beispiel #12
0
        public void EvaluateTest2()
        {
            // Arrange
            IntPtr plugin   = IntPtr.Zero;
            IntPtr userData = IntPtr.Zero;
            double gamma    = 1.0;

            // Act
            using (var context = Context.Create(plugin, userData))
                using (var toneCurve = ToneCurve.BuildGamma(context, gamma))
                {
                    for (ushort i = 0; i < ushort.MaxValue; i++)
                    {
                        ushort actual = toneCurve.Evaluate(i);

                        // Assert
                        Assert.AreEqual(i, actual);
                    }
                }
        }
Beispiel #13
0
        public void ReadTagTest()
        {
            // Arrange
            double expected  = 2.2;
            double precision = 0.01;

            using (var profile = Profile.CreatePlaceholder(null))
            {
                using (var toneCurve = ToneCurve.BuildGamma(null, expected))
                {
                    profile.WriteTag(TagSignature.RedTRC, toneCurve);
                }

                // Act
                using (var toneCurve2 = profile.ReadTag <ToneCurve>(TagSignature.RedTRC))
                {
                    // Assert
                    var actual = toneCurve2.EstimateGamma(precision);
                    Assert.AreEqual(expected, actual, precision);
                }
            }
        }
Beispiel #14
0
        public void CreateTest2()
        {
            // Arrange
            IntPtr plugin    = IntPtr.Zero;
            IntPtr userData  = IntPtr.Zero;
            uint   nChannels = 3;

            using (var context = Context.Create(plugin, userData))
                using (var toneCurve = ToneCurve.BuildGamma(context, 2.2))
                {
                    ToneCurve[] curves = new ToneCurve[3] {
                        toneCurve, toneCurve, toneCurve
                    };

                    // Act
                    using (var stage = Stage.Create(context, nChannels, curves))
                    {
                        // Assert
                        Assert.IsNotNull(stage);
                    }
                }
        }