Ejemplo n.º 1
0
            public void ShouldUseTheReadSettings()
            {
                using (IMagickImage image = new MagickImage())
                {
                    using (FileStream fs = File.OpenRead(Files.Logos.MagickNETSVG))
                    {
                        byte[] buffer = new byte[fs.Length + 1];
                        fs.Read(buffer, 0, (int)fs.Length);

                        using (MemoryStream memStream = new MemoryStream(buffer, 0, (int)fs.Length))
                        {
                            image.Read(memStream, new MagickReadSettings()
                            {
                                Density = new Density(72),
                            });

                            ColorAssert.AreEqual(new MagickColor("#231f20"), image, 129, 101);
                        }
                    }
                }
            }
 private static void Test_Defaults(TextCleanerScript script)
 {
     Assert.AreEqual(0.0, script.AdaptiveBlur);
     ColorAssert.AreEqual(new MagickColor("white"), script.BackgroundColor);
     Assert.AreEqual(0, script.CropOffset.Left);
     Assert.AreEqual(0, script.CropOffset.Top);
     Assert.AreEqual(0, script.CropOffset.Right);
     Assert.AreEqual(0, script.CropOffset.Bottom);
     Assert.AreEqual(TextCleanerEnhance.Stretch, script.Enhance);
     Assert.AreEqual((Percentage)5, script.FilterOffset);
     Assert.AreEqual(15, script.FilterSize);
     Assert.AreEqual(TextCleanerLayout.Portrait, script.Layout);
     Assert.AreEqual(false, script.MakeGray);
     Assert.AreEqual(0, script.Padding);
     Assert.AreEqual(TextCleanerRotation.None, script.Rotation);
     Assert.AreEqual((Percentage)200, script.Saturation);
     Assert.AreEqual(0.0, script.Sharpen);
     Assert.AreEqual(null, script.SmoothingThreshold);
     Assert.AreEqual(false, script.Trim);
     Assert.AreEqual(false, script.Unrotate);
 }
Ejemplo n.º 3
0
        public void Test_FillRule()
        {
            using (IMagickImage image = new MagickImage(MagickColors.SkyBlue, 100, 60))
            {
                Assert.AreEqual(FillRule.EvenOdd, image.Settings.FillRule);

                image.Settings.FillRule    = FillRule.Nonzero;
                image.Settings.FillColor   = MagickColors.White;
                image.Settings.StrokeColor = MagickColors.Black;
                image.Draw(new DrawablePath(
                               new PathMoveToAbs(40, 10),
                               new PathLineToAbs(20, 20),
                               new PathLineToAbs(70, 50),
                               new PathClose(),
                               new PathMoveToAbs(20, 40),
                               new PathLineToAbs(70, 40),
                               new PathLineToAbs(90, 10),
                               new PathClose()));

                ColorAssert.AreEqual(MagickColors.White, image, 50, 30);
            }
        }
Ejemplo n.º 4
0
                public void ShouldCopyTheAlphaChannelWithCopyAlpha()
                {
                    var readSettings = new MagickReadSettings()
                    {
                        BackgroundColor = MagickColors.None,
                        FillColor       = MagickColors.White,
                        FontPointsize   = 100,
                    };

                    using (IMagickImage image = new MagickImage("label:Test", readSettings))
                    {
                        using (IMagickImage alpha = image.Clone())
                        {
                            alpha.Alpha(AlphaOption.Extract);
                            alpha.Shade(130, 30);
                            alpha.Composite(image, CompositeOperator.CopyAlpha);

                            ColorAssert.AreEqual(new MagickColor("#7fff7fff7fff0000"), alpha, 0, 0);
                            ColorAssert.AreEqual(new MagickColor("#7fff7fff7fffffff"), alpha, 30, 30);
                        }
                    }
                }
Ejemplo n.º 5
0
        public void Test_ComplementaryColor()
        {
            ColorRGB color         = MagickColors.Red;
            ColorRGB complementary = color.ComplementaryColor();

            ColorAssert.AreEqual(MagickColors.Aqua, complementary);

            color         = MagickColors.Lime;
            complementary = color.ComplementaryColor();
            ColorAssert.AreEqual(MagickColors.Fuchsia, complementary);

            color         = MagickColors.Black;
            complementary = color.ComplementaryColor();
            ColorAssert.AreEqual(MagickColors.Black, complementary);

            color         = MagickColors.White;
            complementary = color.ComplementaryColor();
            ColorAssert.AreEqual(MagickColors.White, complementary);

            color         = new MagickColor("#aabbcc");
            complementary = color.ComplementaryColor();
            ColorAssert.AreEqual(new MagickColor("#ccbbaa"), complementary);

            color         = new MagickColor(4, 1, 3);
            complementary = color.ComplementaryColor();
            ColorAssert.AreEqual(new MagickColor(1, 4, 1), complementary);

            color         = new MagickColor("#9aa01e");
            complementary = color.ComplementaryColor();
#if Q8
            ColorAssert.AreEqual(new MagickColor("#231ea0"), complementary);
#elif Q16 || Q16HDRI
            ColorAssert.AreEqual(new MagickColor("#24231e1ea0a0"), complementary);
#else
#error Not implemented!
#endif
        }
Ejemplo n.º 6
0
        public void ConvertWithString_TypeIsMagickColor_ReturnsValue()
        {
            MagickColor value = MagickConverter.Convert <MagickColor>("#fff");

            ColorAssert.AreEqual(MagickColors.White, value);
        }
Ejemplo n.º 7
0
        public void Constructor_WithColor_ColorPropertyIsCorrect()
        {
            DrawableBorderColor borderColor = new DrawableBorderColor(Color.GreenYellow);

            ColorAssert.AreEqual(MagickColors.GreenYellow, borderColor.Color);
        }
Ejemplo n.º 8
0
            public void ShouldSetTheProperties()
            {
                DrawableStrokeColor strokeColor = new DrawableStrokeColor(Color.GhostWhite);

                ColorAssert.AreEqual(MagickColors.GhostWhite, strokeColor.Color);
            }
Ejemplo n.º 9
0
        public void ShouldCreateCorrectColorWhenUsingSystemDrawingColor()
        {
            ColorRGB fuchsia = new ColorRGB(Color.Fuchsia);

            ColorAssert.AreEqual(fuchsia, MagickColors.Fuchsia);
        }
Ejemplo n.º 10
0
        public void Constructor_WithColor_ColorPropertyIsCorrect()
        {
            DrawableStrokeColor strokeColor = new DrawableStrokeColor(Color.GhostWhite);

            ColorAssert.AreEqual(MagickColors.GhostWhite, strokeColor.Color);
        }
Ejemplo n.º 11
0
        public void Constructor_WithColor_ColorPropertyIsCorrect()
        {
            DrawableTextUnderColor textUnderColor = new DrawableTextUnderColor(Color.Violet);

            ColorAssert.AreEqual(MagickColors.Violet, textUnderColor.Color);
        }
Ejemplo n.º 12
0
        public void Constructor_WithSystemDrawingColor_IsEqualToMagickColor()
        {
            ColorRGB fuchsia = new ColorRGB(Color.Fuchsia);

            ColorAssert.AreEqual(fuchsia, MagickColors.Fuchsia);
        }
Ejemplo n.º 13
0
            public void ShouldSetTheProperties()
            {
                DrawableBorderColor borderColor = new DrawableBorderColor(Color.GreenYellow);

                ColorAssert.AreEqual(MagickColors.GreenYellow, borderColor.Color);
            }
Ejemplo n.º 14
0
        public void Equals_MagickColorWithConstructedWithStringSetToTransparent_EqualToColorTransparent()
        {
            MagickColor transparent = new MagickColor("transparent");

            ColorAssert.AreEqual(Color.Transparent, transparent);
        }
Ejemplo n.º 15
0
        public void Equals_MagickColorTransparent_EqualToColorTransparent()
        {
            MagickColor transparent = MagickColors.Transparent;

            ColorAssert.AreEqual(Color.Transparent, transparent);
        }
Ejemplo n.º 16
0
            public void Constructor_WithColor_ColorPropertyIsCorrect()
            {
                DrawableFillColor fillColor = new DrawableFillColor(Color.DarkKhaki);

                ColorAssert.AreEqual(MagickColors.DarkKhaki, fillColor.Color);
            }
Ejemplo n.º 17
0
            public void ShouldSetTheProperties()
            {
                DrawableTextUnderColor textUnderColor = new DrawableTextUnderColor(Color.Violet);

                ColorAssert.AreEqual(MagickColors.Violet, textUnderColor.Color);
            }