optimize image processor when gdi can be skipped

This commit is contained in:
Luke Pulverenti
2013-11-07 10:57:12 -05:00
parent d609d0edec
commit 2fc662c9e9
7 changed files with 153 additions and 70 deletions

View File

@@ -1,4 +1,5 @@
using System.Globalization;
namespace MediaBrowser.Model.Drawing
{
/// <summary>
@@ -131,20 +132,77 @@ namespace MediaBrowser.Model.Drawing
/// </summary>
public struct ImageSize
{
private static readonly CultureInfo UsCulture = new CultureInfo("en-US");
private double _height;
private double _width;
/// <summary>
/// Gets or sets the height.
/// </summary>
/// <value>The height.</value>
public double Height { get; set; }
public double Height
{
get
{
return _height;
}
set
{
_height = value;
}
}
/// <summary>
/// Gets or sets the width.
/// </summary>
/// <value>The width.</value>
public double Width { get; set; }
public double Width
{
get { return _width; }
set { _width = value; }
}
public bool Equals(ImageSize size)
{
return Width.Equals(size.Width) && Height.Equals(size.Height);
}
public override string ToString()
{
return string.Format("{0}-{1}", Width, Height);
}
public ImageSize(string value)
{
_width = 0;
_height = 0;
ParseValue(value);
}
private void ParseValue(string value)
{
if (!string.IsNullOrEmpty(value))
{
var parts = value.Split('-');
if (parts.Length == 2)
{
double val;
if (double.TryParse(parts[0], NumberStyles.Any, UsCulture, out val))
{
_width = val;
}
if (double.TryParse(parts[1], NumberStyles.Any, UsCulture, out val))
{
_height = val;
}
}
}
}
}
}