replace System.Drawing with ImageMagick

This commit is contained in:
Luke Pulverenti
2015-02-19 20:57:10 -05:00
parent d155139e28
commit 5e10e0ff19
8 changed files with 175 additions and 537 deletions

View File

@@ -1,31 +1,41 @@
using System.Drawing;
using ImageMagickSharp;
using MediaBrowser.Model.Drawing;
namespace MediaBrowser.Server.Implementations.Drawing
{
public class PlayedIndicatorDrawer
{
private const int IndicatorHeight = 40;
public const int IndicatorWidth = 40;
private const int FontSize = 40;
private const int OffsetFromTopRightCorner = 10;
private const int FontSize = 52;
private const int OffsetFromTopRightCorner = 38;
public void DrawPlayedIndicator(Graphics graphics, Size imageSize)
public void DrawPlayedIndicator(MagickWand wand, ImageSize imageSize)
{
var x = imageSize.Width - IndicatorWidth - OffsetFromTopRightCorner;
var x = imageSize.Width - OffsetFromTopRightCorner;
using (var backdroundBrush = new SolidBrush(Color.FromArgb(225, 82, 181, 75)))
using (var draw = new DrawingWand())
{
graphics.FillEllipse(backdroundBrush, x, OffsetFromTopRightCorner, IndicatorWidth, IndicatorHeight);
x = imageSize.Width - 45 - OffsetFromTopRightCorner;
using (var font = new Font("Webdings", FontSize, FontStyle.Regular, GraphicsUnit.Pixel))
using (PixelWand pixel = new PixelWand())
{
using (var fontBrush = new SolidBrush(Color.White))
{
graphics.DrawString("a", font, fontBrush, x, OffsetFromTopRightCorner - 2);
}
pixel.Color = "#52B54B";
pixel.Opacity = 0.2;
draw.FillColor = pixel;
draw.DrawCircle(x, OffsetFromTopRightCorner, x - 20, OffsetFromTopRightCorner - 20);
pixel.Opacity = 0;
pixel.Color = "white";
draw.FillColor = pixel;
draw.Font = "Webdings";
draw.FontSize = FontSize;
draw.FontStyle = FontStyleType.NormalStyle;
draw.TextAlignment = TextAlignType.CenterAlign;
draw.FontWeight = FontWeightType.RegularStyle;
draw.TextAntialias = true;
draw.DrawAnnotation(x + 4, OffsetFromTopRightCorner + 14, "a");
draw.FillColor = pixel;
wand.CurrentImage.DrawImage(draw);
}
}
}
}