diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-09-19 20:53:18 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-09-19 20:53:18 -0400 |
| commit | b7a8b92c0011c5411a691d522a414480c4c5e34c (patch) | |
| tree | 3a84dbd4d5cd1c78561a92c2a9283ac9cf687b52 /MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs | |
| parent | 04468452ea873e83811522180a0423ac72d6f77d (diff) | |
reduce system info refreshing from dashboard
Diffstat (limited to 'MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs')
| -rw-r--r-- | MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs | 47 |
1 files changed, 32 insertions, 15 deletions
diff --git a/MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs b/MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs index ff532b9dd..c9f9af4f2 100644 --- a/MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs +++ b/MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs @@ -208,15 +208,27 @@ namespace MediaBrowser.Server.Implementations.Drawing private WatchedIndicatorDrawer _watchedDrawer; - private void DrawIndicator(Graphics graphics, int imageWidth, int imageHeight, ImageOverlay indicator) + private void DrawIndicator(Graphics graphics, int imageWidth, int imageHeight, ImageOverlay? indicator) { - if (indicator == ImageOverlay.Watched) + if (!indicator.HasValue) { - _watchedDrawer = _watchedDrawer ?? (_watchedDrawer = new WatchedIndicatorDrawer()); + return; + } + + try + { + if (indicator.Value == ImageOverlay.Watched) + { + _watchedDrawer = _watchedDrawer ?? (_watchedDrawer = new WatchedIndicatorDrawer()); - var currentImageSize = new Size(imageWidth, imageHeight); + var currentImageSize = new Size(imageWidth, imageHeight); - _watchedDrawer.Process(graphics, currentImageSize); + _watchedDrawer.Process(graphics, currentImageSize); + } + } + catch (Exception ex) + { + _logger.ErrorException("Error drawing indicator overlay", ex); } } @@ -338,7 +350,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) + private string GetCacheFilePath(string originalPath, ImageSize outputSize, int quality, DateTime dateModified, ImageOutputFormat format, ImageOverlay? overlay) { var filename = originalPath; @@ -355,9 +367,9 @@ namespace MediaBrowser.Server.Implementations.Drawing filename += "format=" + format; } - if (overlay != ImageOverlay.None) + if (overlay.HasValue) { - filename += "overlay=" + overlay; + filename += "overlay=" + overlay.Value; } return GetCachePath(_resizedImageCachePath, filename, Path.GetExtension(originalPath)); @@ -414,9 +426,13 @@ namespace MediaBrowser.Server.Implementations.Drawing try { - var result = File.ReadAllText(fullCachePath).Split('|').Select(i => double.Parse(i, UsCulture)).ToArray(); + var result = File.ReadAllText(fullCachePath).Split('|'); - return new ImageSize { Width = result[0], Height = result[1] }; + return new ImageSize + { + Width = double.Parse(result[0], UsCulture), + Height = double.Parse(result[1], UsCulture) + }; } catch (IOException) { @@ -429,12 +445,13 @@ namespace MediaBrowser.Server.Implementations.Drawing { try { - var result = File.ReadAllText(fullCachePath) - .Split('|') - .Select(i => double.Parse(i, UsCulture)) - .ToArray(); + var result = File.ReadAllText(fullCachePath).Split('|'); - return new ImageSize { Width = result[0], Height = result[1] }; + return new ImageSize + { + Width = double.Parse(result[0], UsCulture), + Height = double.Parse(result[1], UsCulture) + }; } catch (FileNotFoundException) { |
