예제 #1
0
        public void Process(MagickWand wand, double percent)
        {
            var currentImage = wand.CurrentImage;
            var height = currentImage.Height;

            using (var draw = new DrawingWand())
            {
                using (PixelWand pixel = new PixelWand())
                {
                    var endX = currentImage.Width - 1;
                    var endY = height - 1;

                    pixel.Color = "black";
                    pixel.Opacity = 0.4;
                    draw.FillColor = pixel;
                    draw.DrawRectangle(0, endY - IndicatorHeight, endX, endY);

                    double foregroundWidth = endX;
                    foregroundWidth *= percent;
                    foregroundWidth /= 100;

                    pixel.Color = "#52B54B";
                    pixel.Opacity = 0;
                    draw.FillColor = pixel;
                    draw.DrawRectangle(0, endY - IndicatorHeight, Convert.ToInt32(Math.Round(foregroundWidth)), endY);
                    wand.CurrentImage.DrawImage(draw);
                }
            }
        }
예제 #2
0
        public void Process(MagickWand wand, double percent)
        {
            var currentImage = wand.CurrentImage;
            var height       = currentImage.Height;

            using (var draw = new DrawingWand())
            {
                using (PixelWand pixel = new PixelWand())
                {
                    var endX = currentImage.Width - 1;
                    var endY = height - 1;

                    pixel.Color    = "black";
                    pixel.Opacity  = 0.4;
                    draw.FillColor = pixel;
                    draw.DrawRectangle(0, endY - IndicatorHeight, endX, endY);

                    double foregroundWidth = endX;
                    foregroundWidth *= percent;
                    foregroundWidth /= 100;

                    pixel.Color    = "#52B54B";
                    pixel.Opacity  = 0;
                    draw.FillColor = pixel;
                    draw.DrawRectangle(0, endY - IndicatorHeight, Convert.ToInt32(Math.Round(foregroundWidth)), endY);
                    wand.CurrentImage.DrawImage(draw);
                }
            }
        }
 /// <summary> A MagickWand extension method that draw rectangle. </summary>
 /// <param name="wand"> The wand to act on. </param>
 /// <param name="x1"> The first x value. </param>
 /// <param name="y1"> The first y value. </param>
 /// <param name="x2"> The second x value. </param>
 /// <param name="y2"> The second y value. </param>
 /// <param name="strokeColor"> The stroke color. </param>
 /// <param name="fillcolor"> The fillcolor. </param>
 internal static void DrawRectangle(this ImageWand wand, double x1, double y1, double x2, double y2, PixelWand strokeColor, PixelWand fillcolor)
 {
     using (var draw = new DrawingWand())
     {
         draw.StrokeColor = strokeColor;
         draw.FillColor = fillcolor;
         draw.DrawRectangle(x1, y1, x2, y2);
         wand.DrawImage(draw);
     }
 }
 /// <summary> A MagickWand extension method that draw rectangle. </summary>
 /// <param name="wand"> The wand to act on. </param>
 /// <param name="x1"> The first x value. </param>
 /// <param name="y1"> The first y value. </param>
 /// <param name="x2"> The second x value. </param>
 /// <param name="y2"> The second y value. </param>
 /// <param name="strokeColor"> The stroke color. </param>
 /// <param name="fillcolor"> The fillcolor. </param>
 internal static void DrawRectangle(this ImageWand wand, double x1, double y1, double x2, double y2, PixelWand strokeColor, PixelWand fillcolor)
 {
     using (var draw = new DrawingWand())
     {
         draw.StrokeColor = strokeColor;
         draw.FillColor   = fillcolor;
         draw.DrawRectangle(x1, y1, x2, y2);
         wand.DrawImage(draw);
     }
 }
예제 #5
0
        public void DrawingWandRectangleTest()
        {
            using (var wand = new MagickWand(TestImageBackdrop))
            {
                //wand.NewImage(400, 200, new PixelWand("white"));
                //wand.OpenImage(TestImageBackdrop);
                using (var draw = new DrawingWand())
                {
                    using (PixelWand pixel = new PixelWand())
                    {
                        pixel.Color      = "red";
                        draw.StrokeColor = pixel;
                        pixel.Color      = "black";
                        pixel.Opacity    = 0.5;
                        draw.FillColor   = pixel;
                        draw.DrawRectangle(0, 0, wand.CurrentImage.Width - 1, 120);

                        pixel.Color        = "transparent";
                        draw.StrokeColor   = pixel;
                        pixel.Color        = "white";
                        draw.FillColor     = pixel;
                        draw.Font          = "Verdana";
                        draw.FontSize      = 120;
                        draw.FontStyle     = FontStyleType.NormalStyle;
                        draw.TextAlignment = TextAlignType.LeftAlign;
                        draw.FontWeight    = FontWeightType.BoldStyle;
                        draw.TextAntialias = true;
                        draw.DrawAnnotation(10, 100, "Media Browser");



                        draw.FillColor = pixel;
                        wand.CurrentImage.DrawImage(draw);
                    }
                }
                //Debug.WriteLine(wand.GetNumberImages());
                //wand.Image.TrimImage(10);
                wand.SaveImage(Path.Combine(SaveDirectory, "logo_extent.jpg"));
            }
        }
        public void DrawingWandRectangleTest()
        {
            using (var wand = new MagickWand(TestImageBackdrop))
            {
                //wand.NewImage(400, 200, new PixelWand("white"));
                //wand.OpenImage(TestImageBackdrop);
                using (var draw = new DrawingWand())
                {
                    using (PixelWand pixel = new PixelWand())
                    {

                        pixel.Color = "red";
                        draw.StrokeColor = pixel;
                        pixel.Color = "black";
                        pixel.Opacity = 0.5;
                        draw.FillColor = pixel;
                        draw.DrawRectangle(0, 0, wand.CurrentImage.Width - 1, 120);

                        pixel.Color = "transparent";
                        draw.StrokeColor = pixel;
                        pixel.Color = "white";
                        draw.FillColor = pixel;
                        draw.Font = "Verdana";
                        draw.FontSize = 120;
                        draw.FontStyle = FontStyleType.NormalStyle;
                        draw.TextAlignment = TextAlignType.LeftAlign;
                        draw.FontWeight = FontWeightType.BoldStyle;
                        draw.TextAntialias = true;
                        draw.DrawAnnotation(10, 100, "Media Browser");

                        draw.FillColor = pixel;
                        wand.CurrentImage.DrawImage(draw);
                    }

                }
                //Debug.WriteLine(wand.GetNumberImages());
                //wand.Image.TrimImage(10);
                wand.SaveImage(Path.Combine(SaveDirectory, "logo_extent.jpg"));

            }
        }