PlayedIndicatorDrawer.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using ImageMagickSharp;
  2. using MediaBrowser.Model.Drawing;
  3. namespace MediaBrowser.Server.Implementations.Drawing
  4. {
  5. public class PlayedIndicatorDrawer
  6. {
  7. private const int FontSize = 52;
  8. private const int OffsetFromTopRightCorner = 38;
  9. public void DrawPlayedIndicator(MagickWand wand, ImageSize imageSize)
  10. {
  11. var x = imageSize.Width - OffsetFromTopRightCorner;
  12. using (var draw = new DrawingWand())
  13. {
  14. using (PixelWand pixel = new PixelWand())
  15. {
  16. pixel.Color = "#52B54B";
  17. pixel.Opacity = 0.2;
  18. draw.FillColor = pixel;
  19. draw.DrawCircle(x, OffsetFromTopRightCorner, x - 20, OffsetFromTopRightCorner - 20);
  20. pixel.Opacity = 0;
  21. pixel.Color = "white";
  22. draw.FillColor = pixel;
  23. draw.Font = "Webdings";
  24. draw.FontSize = FontSize;
  25. draw.FontStyle = FontStyleType.NormalStyle;
  26. draw.TextAlignment = TextAlignType.CenterAlign;
  27. draw.FontWeight = FontWeightType.RegularStyle;
  28. draw.TextAntialias = true;
  29. draw.DrawAnnotation(x + 4, OffsetFromTopRightCorner + 14, "a");
  30. draw.FillColor = pixel;
  31. wand.CurrentImage.DrawImage(draw);
  32. }
  33. }
  34. }
  35. }
  36. }