From 6ed380ed1be293ef636570cf2f16c9c95f0858eb Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 5 Jan 2014 16:53:22 -0500 Subject: only call set resolution if we have positive x and y values --- MediaBrowser.Controller/Drawing/ImageExtensions.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'MediaBrowser.Controller/Drawing/ImageExtensions.cs') diff --git a/MediaBrowser.Controller/Drawing/ImageExtensions.cs b/MediaBrowser.Controller/Drawing/ImageExtensions.cs index a7dbc701f..8e75c5210 100644 --- a/MediaBrowser.Controller/Drawing/ImageExtensions.cs +++ b/MediaBrowser.Controller/Drawing/ImageExtensions.cs @@ -170,7 +170,7 @@ namespace MediaBrowser.Controller.Drawing var thumbnail = new Bitmap(croppedWidth, croppedHeight, PixelFormat.Format32bppPArgb); // Preserve the original resolution - thumbnail.SetResolution(bmp.HorizontalResolution, bmp.VerticalResolution); + TrySetResolution(thumbnail, bmp.HorizontalResolution, bmp.VerticalResolution); using (var thumbnailGraph = Graphics.FromImage(thumbnail)) { @@ -188,6 +188,20 @@ namespace MediaBrowser.Controller.Drawing return thumbnail; } + /// + /// Tries the set resolution. + /// + /// The BMP. + /// The x. + /// The y. + private static void TrySetResolution(Bitmap bmp, float x, float y) + { + if (x > 0 && y > 0) + { + bmp.SetResolution(bmp.HorizontalResolution, bmp.VerticalResolution); + } + } + /// /// Determines whether or not a row of pixels is all whitespace /// -- cgit v1.2.3