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 +++++++++++++--------- .../Drawing/PercentPlayedDrawer.cs | 6 ++-- .../Drawing/WatchedIndicatorDrawer.cs | 5 ++-- .../LiveTv/LiveTvManager.cs | 3 +- 4 files changed, 28 insertions(+), 19 deletions(-) (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs b/MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs index 7a16747fbe..d073521496 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)) diff --git a/MediaBrowser.Server.Implementations/Drawing/PercentPlayedDrawer.cs b/MediaBrowser.Server.Implementations/Drawing/PercentPlayedDrawer.cs index 3558244584..e2f5b6129c 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 921494dba6..c889db3044 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"; diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index 87b02816f7..34be46d726 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -38,7 +38,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv return new ChannelInfoDto { Name = info.Name, - ServiceName = info.ServiceName + ServiceName = info.ServiceName, + ChannelType = info.ChannelType }; } } -- cgit v1.2.3