2015-02-19 18:57:10 -07:00
|
|
|
|
using ImageMagickSharp;
|
|
|
|
|
using System;
|
2013-09-21 08:06:00 -07:00
|
|
|
|
|
2015-04-08 07:38:02 -07:00
|
|
|
|
namespace Emby.Drawing.ImageMagick
|
2013-09-21 08:06:00 -07:00
|
|
|
|
{
|
|
|
|
|
public class PercentPlayedDrawer
|
|
|
|
|
{
|
2014-05-27 07:30:21 -07:00
|
|
|
|
private const int IndicatorHeight = 8;
|
2013-09-21 08:06:00 -07:00
|
|
|
|
|
2015-02-19 18:57:10 -07:00
|
|
|
|
public void Process(MagickWand wand, double percent)
|
2013-09-21 08:06:00 -07:00
|
|
|
|
{
|
2015-02-19 18:57:10 -07:00
|
|
|
|
var currentImage = wand.CurrentImage;
|
|
|
|
|
var height = currentImage.Height;
|
2013-09-21 08:06:00 -07:00
|
|
|
|
|
2015-02-19 18:57:10 -07:00
|
|
|
|
using (var draw = new DrawingWand())
|
2013-09-21 08:06:00 -07:00
|
|
|
|
{
|
2015-02-19 18:57:10 -07:00
|
|
|
|
using (PixelWand pixel = new PixelWand())
|
|
|
|
|
{
|
|
|
|
|
var endX = currentImage.Width - 1;
|
|
|
|
|
var endY = height - 1;
|
2013-09-21 08:06:00 -07:00
|
|
|
|
|
2015-02-19 18:57:10 -07:00
|
|
|
|
pixel.Color = "black";
|
|
|
|
|
pixel.Opacity = 0.4;
|
|
|
|
|
draw.FillColor = pixel;
|
|
|
|
|
draw.DrawRectangle(0, endY - IndicatorHeight, endX, endY);
|
2013-09-21 08:06:00 -07:00
|
|
|
|
|
2015-02-19 18:57:10 -07:00
|
|
|
|
double foregroundWidth = endX;
|
2014-01-01 11:26:31 -07:00
|
|
|
|
foregroundWidth *= percent;
|
|
|
|
|
foregroundWidth /= 100;
|
|
|
|
|
|
2015-02-19 18:57:10 -07:00
|
|
|
|
pixel.Color = "#52B54B";
|
|
|
|
|
pixel.Opacity = 0;
|
|
|
|
|
draw.FillColor = pixel;
|
|
|
|
|
draw.DrawRectangle(0, endY - IndicatorHeight, Convert.ToInt32(Math.Round(foregroundWidth)), endY);
|
|
|
|
|
wand.CurrentImage.DrawImage(draw);
|
2013-09-21 08:06:00 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|