aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations/Drawing
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2013-10-02 11:32:11 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2013-10-02 11:32:11 -0400
commit7dae0069d65883d8b2a5ba635991354eb395b7c6 (patch)
tree21c7b523f888f6bbec528534a6d521473bab4dbd /MediaBrowser.Server.Implementations/Drawing
parentf87454336e0bd1f5cb21353a2da116eacfd1adb9 (diff)
added new image params & GameSystem constants
Diffstat (limited to 'MediaBrowser.Server.Implementations/Drawing')
-rw-r--r--MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs33
-rw-r--r--MediaBrowser.Server.Implementations/Drawing/PercentPlayedDrawer.cs6
-rw-r--r--MediaBrowser.Server.Implementations/Drawing/WatchedIndicatorDrawer.cs5
3 files changed, 26 insertions, 18 deletions
diff --git a/MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs b/MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs
index 7a16747fb..d07352149 100644
--- a/MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs
+++ b/MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs
@@ -109,7 +109,7 @@ namespace MediaBrowser.Server.Implementations.Drawing
var quality = options.Quality ?? 90;
- var cacheFilePath = GetCacheFilePath(originalImagePath, newSize, quality, dateModified, options.OutputFormat, options.Indicator, options.PercentPlayed, options.BackgroundColor);
+ var cacheFilePath = GetCacheFilePath(originalImagePath, newSize, quality, dateModified, options.OutputFormat, options.AddPlayedIndicator, options.PercentPlayed, options.BackgroundColor);
try
{
@@ -180,7 +180,7 @@ namespace MediaBrowser.Server.Implementations.Drawing
thumbnailGraph.DrawImage(originalImage, 0, 0, newWidth, newHeight);
- DrawIndicator(thumbnailGraph, newWidth, newHeight, options.Indicator, options.PercentPlayed);
+ DrawIndicator(thumbnailGraph, newWidth, newHeight, options);
var outputFormat = GetOutputFormat(originalImage, options.OutputFormat);
@@ -277,28 +277,31 @@ namespace MediaBrowser.Server.Implementations.Drawing
/// <param name="graphics">The graphics.</param>
/// <param name="imageWidth">Width of the image.</param>
/// <param name="imageHeight">Height of the image.</param>
- /// <param name="indicator">The indicator.</param>
- /// <param name="percentPlayed">The percent played.</param>
- private void DrawIndicator(Graphics graphics, int imageWidth, int imageHeight, ImageOverlay? indicator, int percentPlayed)
+ /// <param name="options">The options.</param>
+ private void DrawIndicator(Graphics graphics, int imageWidth, int imageHeight, ImageProcessingOptions options)
{
- if (!indicator.HasValue)
+ if (!options.AddPlayedIndicator && !options.PercentPlayed.HasValue)
{
return;
}
try
{
- if (indicator.Value == ImageOverlay.Played)
+ var percentOffset = 0;
+
+ if (options.AddPlayedIndicator)
{
var currentImageSize = new Size(imageWidth, imageHeight);
new WatchedIndicatorDrawer().Process(graphics, currentImageSize);
+
+ percentOffset = 0 - WatchedIndicatorDrawer.IndicatorWidth;
}
- if (indicator.Value == ImageOverlay.PercentPlayed)
+ if (options.PercentPlayed.HasValue)
{
var currentImageSize = new Size(imageWidth, imageHeight);
- new PercentPlayedDrawer().Process(graphics, currentImageSize, percentPlayed);
+ new PercentPlayedDrawer().Process(graphics, currentImageSize, options.PercentPlayed.Value, percentOffset);
}
}
catch (Exception ex)
@@ -400,7 +403,7 @@ namespace MediaBrowser.Server.Implementations.Drawing
/// <summary>
/// Gets the cache file path based on a set of parameters
/// </summary>
- private string GetCacheFilePath(string originalPath, ImageSize outputSize, int quality, DateTime dateModified, ImageOutputFormat format, ImageOverlay? overlay, int percentPlayed, string backgroundColor)
+ private string GetCacheFilePath(string originalPath, ImageSize outputSize, int quality, DateTime dateModified, ImageOutputFormat format, bool addPlayedIndicator, int? percentPlayed, string backgroundColor)
{
var filename = originalPath;
@@ -417,10 +420,14 @@ namespace MediaBrowser.Server.Implementations.Drawing
filename += "f=" + format;
}
- if (overlay.HasValue)
+ if (addPlayedIndicator)
+ {
+ filename += "pl=true";
+ }
+
+ if (percentPlayed.HasValue)
{
- filename += "o=" + overlay.Value;
- filename += "p=" + percentPlayed;
+ filename += "p=" + percentPlayed.Value;
}
if (!string.IsNullOrEmpty(backgroundColor))
diff --git a/MediaBrowser.Server.Implementations/Drawing/PercentPlayedDrawer.cs b/MediaBrowser.Server.Implementations/Drawing/PercentPlayedDrawer.cs
index 355824458..e2f5b6129 100644
--- a/MediaBrowser.Server.Implementations/Drawing/PercentPlayedDrawer.cs
+++ b/MediaBrowser.Server.Implementations/Drawing/PercentPlayedDrawer.cs
@@ -10,9 +10,9 @@ namespace MediaBrowser.Server.Implementations.Drawing
private const int FontSize = 30;
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
- public void Process(Graphics graphics, Size imageSize, int percent)
+ public void Process(Graphics graphics, Size imageSize, int percent, int rightOffset)
{
- var x = imageSize.Width - IndicatorWidth;
+ var x = imageSize.Width - IndicatorWidth + rightOffset;
using (var backdroundBrush = new SolidBrush(Color.FromArgb(225, 102, 192, 16)))
{
@@ -20,7 +20,7 @@ namespace MediaBrowser.Server.Implementations.Drawing
var text = string.Format("{0}%", percent.ToString(_usCulture));
- x = imageSize.Width - (percent < 10 ? 66 : 75);
+ x = imageSize.Width - (percent < 10 ? 66 : 75) + rightOffset;
using (var font = new Font(FontFamily.GenericSansSerif, FontSize, FontStyle.Regular, GraphicsUnit.Pixel))
{
diff --git a/MediaBrowser.Server.Implementations/Drawing/WatchedIndicatorDrawer.cs b/MediaBrowser.Server.Implementations/Drawing/WatchedIndicatorDrawer.cs
index 921494dba..c889db304 100644
--- a/MediaBrowser.Server.Implementations/Drawing/WatchedIndicatorDrawer.cs
+++ b/MediaBrowser.Server.Implementations/Drawing/WatchedIndicatorDrawer.cs
@@ -5,15 +5,16 @@ namespace MediaBrowser.Server.Implementations.Drawing
public class WatchedIndicatorDrawer
{
private const int IndicatorHeight = 50;
+ public const int IndicatorWidth = 50;
private const int FontSize = 50;
public void Process(Graphics graphics, Size imageSize)
{
- var x = imageSize.Width - IndicatorHeight;
+ var x = imageSize.Width - IndicatorWidth;
using (var backdroundBrush = new SolidBrush(Color.FromArgb(225, 204, 51, 51)))
{
- graphics.FillRectangle(backdroundBrush, x, 0, IndicatorHeight, IndicatorHeight);
+ graphics.FillRectangle(backdroundBrush, x, 0, IndicatorWidth, IndicatorHeight);
const string text = "a";