aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller/Drawing
diff options
context:
space:
mode:
author7illusions <z@7illusions.com>2014-08-30 19:06:58 +0200
committer7illusions <z@7illusions.com>2014-08-30 19:06:58 +0200
commit66ad1699e22029b605e17735e8d9450285d8748a (patch)
treeffc92c88d24850b2f82b6b3a8bdd904a2ccc77a5 /MediaBrowser.Controller/Drawing
parent34bc54263e886aae777a3537dc50a6535b51330a (diff)
parent9d36f518182bc075c19d78084870f5115fa62d1e (diff)
Merge pull request #1 from MediaBrowser/master
Update to latest
Diffstat (limited to 'MediaBrowser.Controller/Drawing')
-rw-r--r--MediaBrowser.Controller/Drawing/IImageProcessor.cs7
-rw-r--r--MediaBrowser.Controller/Drawing/ImageExtensions.cs33
-rw-r--r--MediaBrowser.Controller/Drawing/ImageProcessingOptions.cs30
3 files changed, 21 insertions, 49 deletions
diff --git a/MediaBrowser.Controller/Drawing/IImageProcessor.cs b/MediaBrowser.Controller/Drawing/IImageProcessor.cs
index 51466c4f92..a0128f1113 100644
--- a/MediaBrowser.Controller/Drawing/IImageProcessor.cs
+++ b/MediaBrowser.Controller/Drawing/IImageProcessor.cs
@@ -73,6 +73,13 @@ namespace MediaBrowser.Controller.Drawing
/// <param name="toStream">To stream.</param>
/// <returns>Task.</returns>
Task ProcessImage(ImageProcessingOptions options, Stream toStream);
+
+ /// <summary>
+ /// Processes the image.
+ /// </summary>
+ /// <param name="options">The options.</param>
+ /// <returns>Task.</returns>
+ Task<string> ProcessImage(ImageProcessingOptions options);
/// <summary>
/// Gets the enhanced image.
diff --git a/MediaBrowser.Controller/Drawing/ImageExtensions.cs b/MediaBrowser.Controller/Drawing/ImageExtensions.cs
index c7e1968e7b..2511659c3f 100644
--- a/MediaBrowser.Controller/Drawing/ImageExtensions.cs
+++ b/MediaBrowser.Controller/Drawing/ImageExtensions.cs
@@ -72,39 +72,6 @@ namespace MediaBrowser.Controller.Drawing
}
/// <summary>
- /// Determines whether [is pixel format supported by graphics object] [the specified format].
- /// </summary>
- /// <param name="format">The format.</param>
- /// <returns><c>true</c> if [is pixel format supported by graphics object] [the specified format]; otherwise, <c>false</c>.</returns>
- public static bool IsPixelFormatSupportedByGraphicsObject(PixelFormat format)
- {
- // http://msdn.microsoft.com/en-us/library/system.drawing.graphics.fromimage.aspx
-
- if ((format & PixelFormat.Indexed) == PixelFormat.Indexed)
- {
- return false;
- }
- if ((format & PixelFormat.Undefined) == PixelFormat.Undefined)
- {
- return false;
- }
- if ((format & PixelFormat.DontCare) == PixelFormat.DontCare)
- {
- return false;
- }
- if ((format & PixelFormat.Format16bppArgb1555) == PixelFormat.Format16bppArgb1555)
- {
- return false;
- }
- if ((format & PixelFormat.Format16bppGrayScale) == PixelFormat.Format16bppGrayScale)
- {
- return false;
- }
-
- return true;
- }
-
- /// <summary>
/// Crops an image by removing whitespace and transparency from the edges
/// </summary>
/// <param name="bmp">The BMP.</param>
diff --git a/MediaBrowser.Controller/Drawing/ImageProcessingOptions.cs b/MediaBrowser.Controller/Drawing/ImageProcessingOptions.cs
index 912ad012d8..f4a76be006 100644
--- a/MediaBrowser.Controller/Drawing/ImageProcessingOptions.cs
+++ b/MediaBrowser.Controller/Drawing/ImageProcessingOptions.cs
@@ -2,6 +2,7 @@
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Drawing;
using System.Collections.Generic;
+using System.IO;
namespace MediaBrowser.Controller.Drawing
{
@@ -34,39 +35,36 @@ namespace MediaBrowser.Controller.Drawing
public int? UnplayedCount { get; set; }
public double? PercentPlayed { get; set; }
-
+
public string BackgroundColor { get; set; }
- public bool HasDefaultOptions()
+ public bool HasDefaultOptions(string originalImagePath)
{
- return HasDefaultOptionsWithoutSize() &&
- !Width.HasValue &&
- !Height.HasValue &&
- !MaxWidth.HasValue &&
+ return HasDefaultOptionsWithoutSize(originalImagePath) &&
+ !Width.HasValue &&
+ !Height.HasValue &&
+ !MaxWidth.HasValue &&
!MaxHeight.HasValue;
}
- public bool HasDefaultOptionsWithoutSize()
+ public bool HasDefaultOptionsWithoutSize(string originalImagePath)
{
return (!Quality.HasValue || Quality.Value == 100) &&
- IsOutputFormatDefault &&
+ IsOutputFormatDefault(originalImagePath) &&
!AddPlayedIndicator &&
!PercentPlayed.HasValue &&
!UnplayedCount.HasValue &&
string.IsNullOrEmpty(BackgroundColor);
}
- private bool IsOutputFormatDefault
+ private bool IsOutputFormatDefault(string originalImagePath)
{
- get
+ if (OutputFormat == ImageOutputFormat.Original)
{
- if (OutputFormat == ImageOutputFormat.Original)
- {
- return true;
- }
-
- return false;
+ return true;
}
+
+ return string.Equals(Path.GetExtension(originalImagePath), "." + OutputFormat);
}
}
}