replace System.Drawing with ImageMagick
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using ImageMagickSharp;
|
||||
using System;
|
||||
|
||||
namespace MediaBrowser.Server.Implementations.Drawing
|
||||
{
|
||||
@@ -7,26 +7,32 @@ namespace MediaBrowser.Server.Implementations.Drawing
|
||||
{
|
||||
private const int IndicatorHeight = 8;
|
||||
|
||||
public void Process(Graphics graphics, Size imageSize, double percent)
|
||||
public void Process(MagickWand wand, double percent)
|
||||
{
|
||||
var y = imageSize.Height - IndicatorHeight;
|
||||
var currentImage = wand.CurrentImage;
|
||||
var height = currentImage.Height;
|
||||
|
||||
using (var backdroundBrush = new SolidBrush(Color.FromArgb(225, 0, 0, 0)))
|
||||
using (var draw = new DrawingWand())
|
||||
{
|
||||
const int innerX = 0;
|
||||
var innerY = y;
|
||||
var innerWidth = imageSize.Width;
|
||||
var innerHeight = imageSize.Height;
|
||||
|
||||
graphics.FillRectangle(backdroundBrush, innerX, innerY, innerWidth, innerHeight);
|
||||
|
||||
using (var foregroundBrush = new SolidBrush(Color.FromArgb(82, 181, 75)))
|
||||
using (PixelWand pixel = new PixelWand())
|
||||
{
|
||||
double foregroundWidth = innerWidth;
|
||||
var endX = currentImage.Width - 1;
|
||||
var endY = height - 1;
|
||||
|
||||
pixel.Color = "black";
|
||||
pixel.Opacity = 0.4;
|
||||
draw.FillColor = pixel;
|
||||
draw.DrawRectangle(0, endY - IndicatorHeight, endX, endY);
|
||||
|
||||
double foregroundWidth = endX;
|
||||
foregroundWidth *= percent;
|
||||
foregroundWidth /= 100;
|
||||
|
||||
graphics.FillRectangle(foregroundBrush, innerX, innerY, Convert.ToInt32(Math.Round(foregroundWidth)), innerHeight);
|
||||
pixel.Color = "#52B54B";
|
||||
pixel.Opacity = 0;
|
||||
draw.FillColor = pixel;
|
||||
draw.DrawRectangle(0, endY - IndicatorHeight, Convert.ToInt32(Math.Round(foregroundWidth)), endY);
|
||||
wand.CurrentImage.DrawImage(draw);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user