diff options
| author | Odd Stråbø <oddstr13@openshell.no> | 2021-03-17 19:45:28 +0100 |
|---|---|---|
| committer | Odd Stråbø <oddstr13@openshell.no> | 2021-04-11 08:21:23 +0200 |
| commit | 13d0837b78011925d308e7ff593207b0e1cb330f (patch) | |
| tree | 5ea805d9dbdc08df834e686f832a391c92077af2 /MediaBrowser.Model/Drawing/DrawingUtils.cs | |
| parent | 383aa4e4d9cf4b0997b9277df838728102e0db3c (diff) | |
(mostly)Fix ResizeFill
Diffstat (limited to 'MediaBrowser.Model/Drawing/DrawingUtils.cs')
| -rw-r--r-- | MediaBrowser.Model/Drawing/DrawingUtils.cs | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/MediaBrowser.Model/Drawing/DrawingUtils.cs b/MediaBrowser.Model/Drawing/DrawingUtils.cs index 8fb9bdc0a..c2a144f81 100644 --- a/MediaBrowser.Model/Drawing/DrawingUtils.cs +++ b/MediaBrowser.Model/Drawing/DrawingUtils.cs @@ -58,7 +58,7 @@ namespace MediaBrowser.Model.Drawing } /// <summary> - /// Resizes to fill box. + /// Scale down to fill box. /// Returns original size if both width and height are null or zero. /// </summary> /// <param name="size">The original size object.</param> @@ -71,9 +71,8 @@ namespace MediaBrowser.Model.Drawing int? fillHeight) { // Return original size if input is invalid. - if ( - (fillWidth == null && fillHeight == null) - || (fillWidth == 0 || fillHeight == 0)) + if ((fillWidth == null || fillWidth == 0) + && (fillHeight == null || fillHeight == 0)) { return size; } @@ -89,9 +88,8 @@ namespace MediaBrowser.Model.Drawing } double widthRatio = (double)size.Width / (double)fillWidth; - double heightRatio = (double)size.Height / (double)fillHeight!; - // min() - double scaleRatio = widthRatio > heightRatio ? heightRatio : widthRatio; + double heightRatio = (double)size.Height / (double)fillHeight; + double scaleRatio = Math.Min(widthRatio, heightRatio); // Clamp to current size. if (scaleRatio < 1) |
