From dc09bb8c0847cec812364ee6f32be055741e76dc Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 24 Aug 2016 23:44:59 -0400 Subject: [PATCH] fix dynamic images for osx --- Emby.Drawing/GDI/DynamicImageHelpers.cs | 48 ++++++------------------- 1 file changed, 10 insertions(+), 38 deletions(-) diff --git a/Emby.Drawing/GDI/DynamicImageHelpers.cs b/Emby.Drawing/GDI/DynamicImageHelpers.cs index 7b8ef2f98..e0ce90120 100644 --- a/Emby.Drawing/GDI/DynamicImageHelpers.cs +++ b/Emby.Drawing/GDI/DynamicImageHelpers.cs @@ -33,7 +33,9 @@ namespace Emby.Drawing.GDI graphics.SmoothingMode = SmoothingMode.HighQuality; graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; - graphics.CompositingMode = CompositingMode.SourceCopy; + + // This causes the image to be blank in OSX + //graphics.CompositingMode = CompositingMode.SourceCopy; for (var row = 0; row < rows; row++) { @@ -44,19 +46,9 @@ namespace Emby.Drawing.GDI if (files.Count > index) { - using (var fileStream = fileSystem.GetFileStream(files[index], FileMode.Open, FileAccess.Read, FileShare.Read, true)) + using (var imgtemp = Image.FromFile(files[index])) { - using (var memoryStream = new MemoryStream()) - { - fileStream.CopyTo(memoryStream); - - memoryStream.Position = 0; - - using (var imgtemp = Image.FromStream(memoryStream, true, false)) - { - graphics.DrawImage(imgtemp, x, y, cellWidth, cellHeight); - } - } + graphics.DrawImage(imgtemp, x, y, cellWidth, cellHeight); } } @@ -90,7 +82,9 @@ namespace Emby.Drawing.GDI graphics.SmoothingMode = SmoothingMode.HighQuality; graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; - graphics.CompositingMode = CompositingMode.SourceCopy; + + // This causes the image to be blank in OSX + //graphics.CompositingMode = CompositingMode.SourceCopy; for (var row = 0; row < rows; row++) { @@ -99,21 +93,10 @@ namespace Emby.Drawing.GDI var x = col * singleSize; var y = row * singleSize; - using (var fileStream = fileSystem.GetFileStream(files[index], FileMode.Open, FileAccess.Read, FileShare.Read, true)) + using (var imgtemp = Image.FromFile(files[index])) { - using (var memoryStream = new MemoryStream()) - { - fileStream.CopyTo(memoryStream); - - memoryStream.Position = 0; - - using (var imgtemp = Image.FromStream(memoryStream, true, false)) - { - graphics.DrawImage(imgtemp, x, y, singleSize, singleSize); - } - } + graphics.DrawImage(imgtemp, x, y, singleSize, singleSize); } - index++; } } @@ -121,16 +104,5 @@ namespace Emby.Drawing.GDI } } } - - private static Stream GetStream(Image image) - { - var ms = new MemoryStream(); - - image.Save(ms, ImageFormat.Png); - - ms.Position = 0; - - return ms; - } } }