only call set resolution if we have positive x and y values

pull/702/head
Luke Pulverenti 11 years ago
parent a01ee815fb
commit 6ed380ed1b

@ -170,7 +170,7 @@ namespace MediaBrowser.Controller.Drawing
var thumbnail = new Bitmap(croppedWidth, croppedHeight, PixelFormat.Format32bppPArgb); var thumbnail = new Bitmap(croppedWidth, croppedHeight, PixelFormat.Format32bppPArgb);
// Preserve the original resolution // Preserve the original resolution
thumbnail.SetResolution(bmp.HorizontalResolution, bmp.VerticalResolution); TrySetResolution(thumbnail, bmp.HorizontalResolution, bmp.VerticalResolution);
using (var thumbnailGraph = Graphics.FromImage(thumbnail)) using (var thumbnailGraph = Graphics.FromImage(thumbnail))
{ {
@ -188,6 +188,20 @@ namespace MediaBrowser.Controller.Drawing
return thumbnail; return thumbnail;
} }
/// <summary>
/// Tries the set resolution.
/// </summary>
/// <param name="bmp">The BMP.</param>
/// <param name="x">The x.</param>
/// <param name="y">The y.</param>
private static void TrySetResolution(Bitmap bmp, float x, float y)
{
if (x > 0 && y > 0)
{
bmp.SetResolution(bmp.HorizontalResolution, bmp.VerticalResolution);
}
}
/// <summary> /// <summary>
/// Determines whether or not a row of pixels is all whitespace /// Determines whether or not a row of pixels is all whitespace
/// </summary> /// </summary>

@ -229,7 +229,7 @@ namespace MediaBrowser.Server.Implementations.Drawing
using (var thumbnail = new Bitmap(newWidth, newHeight, PixelFormat.Format32bppPArgb)) using (var thumbnail = new Bitmap(newWidth, newHeight, PixelFormat.Format32bppPArgb))
{ {
// Mono throw an exeception if assign 0 to SetResolution // Mono throw an exeception if assign 0 to SetResolution
if (originalImage.HorizontalResolution >= 0 && originalImage.VerticalResolution >= 0) if (originalImage.HorizontalResolution > 0 && originalImage.VerticalResolution > 0)
{ {
// Preserve the original resolution // Preserve the original resolution
thumbnail.SetResolution(originalImage.HorizontalResolution, originalImage.VerticalResolution); thumbnail.SetResolution(originalImage.HorizontalResolution, originalImage.VerticalResolution);

Loading…
Cancel
Save