From 7dae0069d65883d8b2a5ba635991354eb395b7c6 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 2 Oct 2013 11:32:11 -0400 Subject: added new image params & GameSystem constants --- .../Drawing/ImageProcessor.cs | 33 +++++++++++++--------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs') 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 /// The graphics. /// Width of the image. /// Height of the image. - /// The indicator. - /// The percent played. - private void DrawIndicator(Graphics graphics, int imageWidth, int imageHeight, ImageOverlay? indicator, int percentPlayed) + /// The options. + 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 /// /// Gets the cache file path based on a set of parameters /// - 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)) -- cgit v1.2.3