jellyfin/Emby.Drawing.ImageMagick/PercentPlayedDrawer.cs

41 lines
1.3 KiB
C#
Raw Normal View History

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