aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Api/Drawing/DrawingUtils.cs
diff options
context:
space:
mode:
authorLukePulverenti <luke.pulverenti@gmail.com>2013-02-20 20:33:05 -0500
committerLukePulverenti <luke.pulverenti@gmail.com>2013-02-20 20:33:05 -0500
commit767cdc1f6f6a63ce997fc9476911e2c361f9d402 (patch)
tree49add55976f895441167c66cfa95e5c7688d18ce /MediaBrowser.Api/Drawing/DrawingUtils.cs
parent845554722efaed872948a9e0f7202e3ef52f1b6e (diff)
Pushing missing changes
Diffstat (limited to 'MediaBrowser.Api/Drawing/DrawingUtils.cs')
-rw-r--r--MediaBrowser.Api/Drawing/DrawingUtils.cs81
1 files changed, 0 insertions, 81 deletions
diff --git a/MediaBrowser.Api/Drawing/DrawingUtils.cs b/MediaBrowser.Api/Drawing/DrawingUtils.cs
deleted file mode 100644
index f76a74218..000000000
--- a/MediaBrowser.Api/Drawing/DrawingUtils.cs
+++ /dev/null
@@ -1,81 +0,0 @@
-using System;
-using System.Drawing;
-
-namespace MediaBrowser.Api.Drawing
-{
- public static class DrawingUtils
- {
- /// <summary>
- /// Resizes a set of dimensions
- /// </summary>
- public static Size Resize(int currentWidth, int currentHeight, int? width, int? height, int? maxWidth, int? maxHeight)
- {
- return Resize(new Size(currentWidth, currentHeight), width, height, maxWidth, maxHeight);
- }
-
- /// <summary>
- /// Resizes a set of dimensions
- /// </summary>
- /// <param name="size">The original size object</param>
- /// <param name="width">A new fixed width, if desired</param>
- /// <param name="height">A new fixed neight, if desired</param>
- /// <param name="maxWidth">A max fixed width, if desired</param>
- /// <param name="maxHeight">A max fixed height, if desired</param>
- /// <returns>A new size object</returns>
- public static Size Resize(Size size, int? width, int? height, int? maxWidth, int? maxHeight)
- {
- decimal newWidth = size.Width;
- decimal newHeight = size.Height;
-
- if (width.HasValue && height.HasValue)
- {
- newWidth = width.Value;
- newHeight = height.Value;
- }
-
- else if (height.HasValue)
- {
- newWidth = GetNewWidth(newHeight, newWidth, height.Value);
- newHeight = height.Value;
- }
-
- else if (width.HasValue)
- {
- newHeight = GetNewHeight(newHeight, newWidth, width.Value);
- newWidth = width.Value;
- }
-
- if (maxHeight.HasValue && maxHeight < newHeight)
- {
- newWidth = GetNewWidth(newHeight, newWidth, maxHeight.Value);
- newHeight = maxHeight.Value;
- }
-
- if (maxWidth.HasValue && maxWidth < newWidth)
- {
- newHeight = GetNewHeight(newHeight, newWidth, maxWidth.Value);
- newWidth = maxWidth.Value;
- }
-
- return new Size(Convert.ToInt32(newWidth), Convert.ToInt32(newHeight));
- }
-
- private static decimal GetNewWidth(decimal currentHeight, decimal currentWidth, int newHeight)
- {
- decimal scaleFactor = newHeight;
- scaleFactor /= currentHeight;
- scaleFactor *= currentWidth;
-
- return scaleFactor;
- }
-
- private static decimal GetNewHeight(decimal currentHeight, decimal currentWidth, int newWidth)
- {
- decimal scaleFactor = newWidth;
- scaleFactor /= currentWidth;
- scaleFactor *= currentHeight;
-
- return scaleFactor;
- }
- }
-}