예제 #1
0
        private static void AssertDefaults(UnperspectiveScript script, UnperspectiveMethod method)
        {
            Assert.AreEqual(null, script.AspectRatio);
            Assert.AreEqual(0, script.BorderColorLocation.X);
            Assert.AreEqual(0, script.BorderColorLocation.Y);
            Assert.AreEqual(0, script.Blur);
            Assert.AreEqual(UnperspectiveDefault.EdgeLength, script.Default);
            Assert.AreEqual(false, script.DisableViewportCrop);
            Assert.AreEqual(null, script.Height);
            Assert.AreEqual(10, script.MinLength);
            Assert.AreEqual(40, script.MaxPeaks);
            Assert.AreEqual(null, script.Rotation);
            Assert.AreEqual(null, script.Width);

            if (method == UnperspectiveMethod.Peak)
            {
                Assert.AreEqual(5.0, script.Sharpen);
                Assert.AreEqual(1.0, script.Smooth);
                Assert.AreEqual(4, script.Threshold);
            }
            else
            {
                Assert.AreEqual(0.0, script.Sharpen);
                Assert.AreEqual(5.0, script.Smooth);
                Assert.AreEqual(10, script.Threshold);
            }
        }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UnperspectiveScript"/> class.
        /// </summary>
        /// <param name="method">The unpersective method</param>
        public UnperspectiveScript(UnperspectiveMethod method)
        {
            if (method != UnperspectiveMethod.Peak && method != UnperspectiveMethod.Derivative)
            {
                throw new ArgumentException("Invalid unperspective method specified.", nameof(method));
            }

            _method = method;

            Reset();
        }
예제 #3
0
        private static void AssertInvalidOperation(string expectedMessage, UnperspectiveMethod method, Action <UnperspectiveScript> initAction)
        {
            var script = new UnperspectiveScript(method);

            using (var logo = new MagickImage(Images.Logo))
            {
                initAction(script);

                ExceptionAssert.Throws <InvalidOperationException>(expectedMessage, () =>
                {
                    script.Execute(logo);
                });
            }
        }
예제 #4
0
        private void AssertExecute(string input, string methodName, UnperspectiveMethod method, Action <UnperspectiveScript> action)
        {
            var inputFile = GetInputFile(input);

            /* LosslessCompress(input); */

            using (var image = new MagickImage(inputFile))
            {
                var script = new UnperspectiveScript(method);
                action(script);

                using (var scriptOutput = script.Execute(image))
                {
                    string outputFile = GetOutputFile(inputFile, methodName);
                    AssertOutput(scriptOutput, outputFile);
                }
            }
        }
예제 #5
0
        private static void Reset_AllSettingsChanged_RestoredToDefault(UnperspectiveMethod method)
        {
            var script = new UnperspectiveScript(method);

            script.AspectRatio         = 1.5;
            script.BorderColorLocation = new PointD(10, 10);
            script.Blur                = 15.0;
            script.ColorFuzz           = (Percentage)5.0;
            script.Default             = UnperspectiveDefault.BoundingBoxWidth;
            script.DisableViewportCrop = true;
            script.Height              = 140;
            script.MaxPeaks            = 25;
            script.MinLength           = 5;
            script.Rotation            = UnperspectiveRotation.Rotate180;
            script.Sharpen             = 8.5;
            script.Smooth              = 2.0;
            script.Threshold           = 5;
            script.Width               = 50;

            script.Reset();

            AssertDefaults(script, method);
        }
예제 #6
0
        private static void Constructor_SettingsSetToDefaults(UnperspectiveMethod method)
        {
            var script = new UnperspectiveScript(method);

            AssertDefaults(script, method);
        }