PercentPlayedDrawer.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using ImageMagickSharp;
  2. using System;
  3. namespace Emby.Drawing.ImageMagick
  4. {
  5. public class PercentPlayedDrawer
  6. {
  7. private const int IndicatorHeight = 8;
  8. public void Process(MagickWand wand, double percent)
  9. {
  10. var currentImage = wand.CurrentImage;
  11. var height = currentImage.Height;
  12. using (var draw = new DrawingWand())
  13. {
  14. using (PixelWand pixel = new PixelWand())
  15. {
  16. var endX = currentImage.Width - 1;
  17. var endY = height - 1;
  18. pixel.Color = "black";
  19. pixel.Opacity = 0.4;
  20. draw.FillColor = pixel;
  21. draw.DrawRectangle(0, endY - IndicatorHeight, endX, endY);
  22. double foregroundWidth = endX;
  23. foregroundWidth *= percent;
  24. foregroundWidth /= 100;
  25. pixel.Color = "#52B54B";
  26. pixel.Opacity = 0;
  27. draw.FillColor = pixel;
  28. draw.DrawRectangle(0, endY - IndicatorHeight, Convert.ToInt32(Math.Round(foregroundWidth)), endY);
  29. wand.CurrentImage.DrawImage(draw);
  30. }
  31. }
  32. }
  33. }
  34. }