Пример #1
0
        public async Task DrawPlayedIndicator(MagickWand wand, ImageSize imageSize)
        {
            var x = imageSize.Width - OffsetFromTopRightCorner;

            using (var draw = new DrawingWand())
            {
                using (PixelWand pixel = new PixelWand())
                {
                    pixel.Color    = "#52B54B";
                    pixel.Opacity  = 0.2;
                    draw.FillColor = pixel;
                    draw.DrawCircle(x, OffsetFromTopRightCorner, x - 20, OffsetFromTopRightCorner - 20);

                    pixel.Opacity  = 0;
                    pixel.Color    = "white";
                    draw.FillColor = pixel;
                    draw.Font      = await DownloadFont("webdings.ttf", "https://github.com/MediaBrowser/Emby.Resources/raw/master/fonts/webdings.ttf", _appPaths, _iHttpClient, _fileSystem).ConfigureAwait(false);

                    draw.FontSize      = FontSize;
                    draw.FontStyle     = FontStyleType.NormalStyle;
                    draw.TextAlignment = TextAlignType.CenterAlign;
                    draw.FontWeight    = FontWeightType.RegularStyle;
                    draw.TextAntialias = true;
                    draw.DrawAnnotation(x + 4, OffsetFromTopRightCorner + 14, "a");

                    draw.FillColor = pixel;
                    wand.CurrentImage.DrawImage(draw);
                }
            }
        }
        public void DrawPlayedIndicator(MagickWand wand, ImageSize imageSize)
        {
            var x = imageSize.Width - OffsetFromTopRightCorner;

            using (var draw = new DrawingWand())
            {
                using (PixelWand pixel = new PixelWand())
                {
                    pixel.Color    = "#52B54B";
                    pixel.Opacity  = 0.2;
                    draw.FillColor = pixel;
                    draw.DrawCircle(x, OffsetFromTopRightCorner, x - 20, OffsetFromTopRightCorner - 20);

                    pixel.Opacity      = 0;
                    pixel.Color        = "white";
                    draw.FillColor     = pixel;
                    draw.Font          = ExtractFont("webdings.ttf", _appPaths);
                    draw.FontSize      = FontSize;
                    draw.FontStyle     = FontStyleType.NormalStyle;
                    draw.TextAlignment = TextAlignType.CenterAlign;
                    draw.FontWeight    = FontWeightType.RegularStyle;
                    draw.TextAntialias = true;
                    draw.DrawAnnotation(x + 4, OffsetFromTopRightCorner + 14, "a");

                    draw.FillColor = pixel;
                    wand.CurrentImage.DrawImage(draw);
                }
            }
        }
Пример #3
0
 public void DrawingWandAnnotationTest()
 {
     //using (var wand = new MagickWand(TestImageBackdrop))
     using (var wand = new MagickWand(400, 100, "#ffffff"))
     {
         //wand.NewImage(400, 200, new PixelWand("white"));
         //wand.OpenImage(TestImageBackdrop);
         using (var draw = new DrawingWand())
         {
             using (PixelWand pixel = new PixelWand("black"))
             {
                 draw.FillColor     = pixel;
                 draw.Font          = "Arial";
                 draw.FontSize      = 20;
                 draw.FontStyle     = FontStyleType.NormalStyle;
                 draw.TextAlignment = TextAlignType.LeftAlign;
                 draw.FontWeight    = FontWeightType.BoldStyle;
                 draw.TextAntialias = true;
                 draw.DrawAnnotation(0, 20, "Media Browser");
                 draw.BorderColor = new PixelWand("red");
                 //draw.Font = "Times-New-Roman";
                 //pixel.Color = "Red";
                 //pixel.Opacity = 0.8;
                 //draw.FillColor = pixel;
                 //draw.DrawAnnotation(60, 120, "Tavares");
                 Debug.WriteLine(draw);
                 wand.CurrentImage.DrawImage(draw);
             }
         }
         //Debug.WriteLine(wand.GetNumberImages());
         //wand.Image.TrimImage(10);
         wand.SaveImage(Path.Combine(SaveDirectory, "logo_extent.jpg"));
     }
 }
Пример #4
0
        public async Task DrawPlayedIndicator(MagickWand wand, ImageSize imageSize)
        {
            var x = imageSize.Width - OffsetFromTopRightCorner;

            using (var draw = new DrawingWand())
            {
                using (PixelWand pixel = new PixelWand())
                {
                    pixel.Color = "#52B54B";
                    pixel.Opacity = 0.2;
                    draw.FillColor = pixel;
                    draw.DrawCircle(x, OffsetFromTopRightCorner, x - 20, OffsetFromTopRightCorner - 20);

                    pixel.Opacity = 0;
                    pixel.Color = "white";
                    draw.FillColor = pixel;
                    draw.Font = await DownloadFont("webdings.ttf", "https://github.com/MediaBrowser/Emby.Resources/raw/master/fonts/webdings.ttf", _appPaths, _iHttpClient, _fileSystem).ConfigureAwait(false);
                    draw.FontSize = FontSize;
                    draw.FontStyle = FontStyleType.NormalStyle;
                    draw.TextAlignment = TextAlignType.CenterAlign;
                    draw.FontWeight = FontWeightType.RegularStyle;
                    draw.TextAntialias = true;
                    draw.DrawAnnotation(x + 4, OffsetFromTopRightCorner + 14, "a");

                    draw.FillColor = pixel;
                    wand.CurrentImage.DrawImage(draw);
                }
            }
        }
Пример #5
0
        public void DrawUnplayedCountIndicator(MagickWand wand, ImageSize imageSize, int count)
        {
            var x = imageSize.Width - OffsetFromTopRightCorner;
            var text = count.ToString(CultureInfo.InvariantCulture);

            using (var draw = new DrawingWand())
            {
                using (PixelWand pixel = new PixelWand())
                {
                    pixel.Color = "#52B54B";
                    pixel.Opacity = 0.2;
                    draw.FillColor = pixel;
                    draw.DrawCircle(x, OffsetFromTopRightCorner, x - 20, OffsetFromTopRightCorner - 20);

                    pixel.Opacity = 0;
                    pixel.Color = "white";
                    draw.FillColor = pixel;
                    draw.Font = PlayedIndicatorDrawer.ExtractFont("robotoregular.ttf", _appPaths, _fileSystem);
                    draw.FontStyle = FontStyleType.NormalStyle;
                    draw.TextAlignment = TextAlignType.CenterAlign;
                    draw.FontWeight = FontWeightType.RegularStyle;
                    draw.TextAntialias = true;

                    var fontSize = 30;
                    var y = OffsetFromTopRightCorner + 11;

                    if (text.Length == 1)
                    {
                        x += 1;
                    }
                    else if (text.Length == 2)
                    {
                        x += 1;
                    }
                    else if (text.Length >= 3)
                    {
                        //x += 1;
                        y -= 2;
                        fontSize = 24;
                    }

                    draw.FontSize = fontSize;
                    draw.DrawAnnotation(x, y, text);

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

            }
        }
Пример #6
0
        public void DrawUnplayedCountIndicator(MagickWand wand, ImageSize imageSize, int count)
        {
            var x    = imageSize.Width - OffsetFromTopRightCorner;
            var text = count.ToString(CultureInfo.InvariantCulture);

            using (var draw = new DrawingWand())
            {
                using (PixelWand pixel = new PixelWand())
                {
                    pixel.Color    = "#52B54B";
                    pixel.Opacity  = 0.2;
                    draw.FillColor = pixel;
                    draw.DrawCircle(x, OffsetFromTopRightCorner, x - 20, OffsetFromTopRightCorner - 20);

                    pixel.Opacity      = 0;
                    pixel.Color        = "white";
                    draw.FillColor     = pixel;
                    draw.Font          = PlayedIndicatorDrawer.ExtractFont("robotoregular.ttf", _appPaths, _fileSystem);
                    draw.FontStyle     = FontStyleType.NormalStyle;
                    draw.TextAlignment = TextAlignType.CenterAlign;
                    draw.FontWeight    = FontWeightType.RegularStyle;
                    draw.TextAntialias = true;

                    var fontSize = 30;
                    var y        = OffsetFromTopRightCorner + 11;

                    if (text.Length == 1)
                    {
                        x += 1;
                    }
                    else if (text.Length == 2)
                    {
                        x += 1;
                    }
                    else if (text.Length >= 3)
                    {
                        //x += 1;
                        y       -= 2;
                        fontSize = 24;
                    }

                    draw.FontSize = fontSize;
                    draw.DrawAnnotation(x, y, text);

                    draw.FillColor = pixel;
                    wand.CurrentImage.DrawImage(draw);
                }
            }
        }
 /// <summary> A MagickWand extension method that draw text. </summary>
 /// <param name="wand"> The wand to act on. </param>
 /// <param name="text"> The text. </param>
 /// <param name="x"> The x coordinate. </param>
 /// <param name="y"> The y coordinate. </param>
 /// <param name="fontName"> Name of the font. </param>
 /// <param name="fontSize"> Size of the font. </param>
 /// <param name="fontColor"> The font color. </param>
 /// <param name="fontWeight"> The font weight. </param>
 internal static void DrawText(this ImageWand wand, string text, double x, double y, string fontName, double fontSize, PixelWand fontColor, FontWeightType fontWeight)
 {
     using (var draw = new DrawingWand())
     {
         using (fontColor)
         {
             draw.FillColor     = fontColor;
             draw.Font          = fontName;
             draw.FontSize      = fontSize;
             draw.FontWeight    = fontWeight;
             draw.TextAntialias = true;
             draw.DrawAnnotation(x, y, text);
             wand.DrawImage(draw);
         }
     }
 }
Пример #8
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 DrawingWandAnnotationTest()
        {
            //using (var wand = new MagickWand(TestImageBackdrop))
            using (var wand = new MagickWand(400, 100, "#ffffff"))
            {
                //wand.NewImage(400, 200, new PixelWand("white"));
                //wand.OpenImage(TestImageBackdrop);
                using (var draw = new DrawingWand())
                {
                    using (PixelWand pixel = new PixelWand("black"))
                    {
                        draw.FillColor = pixel;
                        draw.Font = "Arial";
                        draw.FontSize = 20;
                        draw.FontStyle = FontStyleType.NormalStyle;
                        draw.TextAlignment = TextAlignType.LeftAlign;
                        draw.FontWeight = FontWeightType.BoldStyle;
                        draw.TextAntialias = true;
                        draw.DrawAnnotation(0, 20, "Media Browser");
                        draw.BorderColor = new PixelWand("red");
                        //draw.Font = "Times-New-Roman";
                        //pixel.Color = "Red";
                        //pixel.Opacity = 0.8;
                        //draw.FillColor = pixel;
                        //draw.DrawAnnotation(60, 120, "Tavares");
                        Debug.WriteLine(draw);
                        wand.CurrentImage.DrawImage(draw);
                    }

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

            }
        }
Пример #10
0
        public void DrawingWandCircleTest()
        {
            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.3;
                        draw.FillColor = pixel;
                        draw.DrawCircle(400, 400, 300, 300);

                        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"));

            }
        }
 /// <summary> A MagickWand extension method that draw text. </summary>
 /// <param name="wand"> The wand to act on. </param>
 /// <param name="text"> The text. </param>
 /// <param name="x"> The x coordinate. </param>
 /// <param name="y"> The y coordinate. </param>
 /// <param name="fontName"> Name of the font. </param>
 /// <param name="fontSize"> Size of the font. </param>
 /// <param name="fontColor"> The font color. </param>
 /// <param name="fontWeight"> The font weight. </param>
 internal static void DrawText(this ImageWand wand, string text, double x, double y, string fontName, double fontSize, PixelWand fontColor, FontWeightType fontWeight)
 {
     using (var draw = new DrawingWand())
     {
         using (fontColor)
         {
             draw.FillColor = fontColor;
             draw.Font = fontName;
             draw.FontSize = fontSize;
             draw.FontWeight = fontWeight;
             draw.TextAntialias = true;
             draw.DrawAnnotation(x, y, text);
             wand.DrawImage(draw);
         }
     }
 }