jellyfin-server/MediaBrowser.Server.Implementations/Drawing/PercentPlayedDrawer.cs

41 lines
1.3 KiB
C#
Raw Normal View History

using ImageMagickSharp;
using System;
2013-09-21 15:06:00 +00:00
namespace MediaBrowser.Server.Implementations.Drawing
{
public class PercentPlayedDrawer
{
2014-05-27 14:30:21 +00:00
private const int IndicatorHeight = 8;
2013-09-21 15:06:00 +00:00
public void Process(MagickWand wand, double percent)
2013-09-21 15:06:00 +00:00
{
var currentImage = wand.CurrentImage;
var height = currentImage.Height;
2013-09-21 15:06:00 +00:00
using (var draw = new DrawingWand())
2013-09-21 15:06:00 +00:00
{
using (PixelWand pixel = new PixelWand())
{
var endX = currentImage.Width - 1;
var endY = height - 1;
2013-09-21 15:06:00 +00:00
pixel.Color = "black";
pixel.Opacity = 0.4;
draw.FillColor = pixel;
draw.DrawRectangle(0, endY - IndicatorHeight, endX, endY);
2013-09-21 15:06:00 +00:00
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);
2013-09-21 15:06:00 +00:00
}
}
}
}
}