From dc09bb8c0847cec812364ee6f32be055741e76dc Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 24 Aug 2016 23:44:59 -0400 Subject: fix dynamic images for osx --- Emby.Drawing/GDI/DynamicImageHelpers.cs | 48 +++++++-------------------------- 1 file changed, 10 insertions(+), 38 deletions(-) (limited to 'Emby.Drawing/GDI/DynamicImageHelpers.cs') diff --git a/Emby.Drawing/GDI/DynamicImageHelpers.cs b/Emby.Drawing/GDI/DynamicImageHelpers.cs index 7b8ef2f98a..e0ce901200 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; - } } } -- cgit v1.2.3 From f5a6a418f58b26f49ff8fc17c32e391f79565105 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 25 Aug 2016 00:54:06 -0400 Subject: update scaling with MaxHeight --- Emby.Drawing/GDI/DynamicImageHelpers.cs | 4 ++-- Emby.Drawing/GDI/GDIImageEncoder.cs | 8 +++++--- MediaBrowser.Api/Playback/BaseStreamingService.cs | 2 +- MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) (limited to 'Emby.Drawing/GDI/DynamicImageHelpers.cs') diff --git a/Emby.Drawing/GDI/DynamicImageHelpers.cs b/Emby.Drawing/GDI/DynamicImageHelpers.cs index e0ce901200..59340af8a9 100644 --- a/Emby.Drawing/GDI/DynamicImageHelpers.cs +++ b/Emby.Drawing/GDI/DynamicImageHelpers.cs @@ -34,7 +34,7 @@ namespace Emby.Drawing.GDI graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; - // This causes the image to be blank in OSX + // SourceCopy causes the image to be blank in OSX //graphics.CompositingMode = CompositingMode.SourceCopy; for (var row = 0; row < rows; row++) @@ -83,7 +83,7 @@ namespace Emby.Drawing.GDI graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; - // This causes the image to be blank in OSX + // SourceCopy causes the image to be blank in OSX //graphics.CompositingMode = CompositingMode.SourceCopy; for (var row = 0; row < rows; row++) diff --git a/Emby.Drawing/GDI/GDIImageEncoder.cs b/Emby.Drawing/GDI/GDIImageEncoder.cs index bdd1c5a22f..afd16899dc 100644 --- a/Emby.Drawing/GDI/GDIImageEncoder.cs +++ b/Emby.Drawing/GDI/GDIImageEncoder.cs @@ -119,9 +119,11 @@ namespace Emby.Drawing.GDI thumbnailGraph.SmoothingMode = SmoothingMode.HighQuality; thumbnailGraph.InterpolationMode = InterpolationMode.HighQualityBicubic; thumbnailGraph.PixelOffsetMode = PixelOffsetMode.HighQuality; - thumbnailGraph.CompositingMode = !hasPostProcessing ? - CompositingMode.SourceCopy : - CompositingMode.SourceOver; + + // SourceCopy causes the image to be blank in OSX + //thumbnailGraph.CompositingMode = !hasPostProcessing ? + // CompositingMode.SourceCopy : + // CompositingMode.SourceOver; SetBackgroundColor(thumbnailGraph, options); diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 6f4b6323d6..a022c83d84 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -644,7 +644,7 @@ namespace MediaBrowser.Api.Playback { var maxHeightParam = request.MaxHeight.Value.ToString(UsCulture); - filters.Add(string.Format("scale=trunc(oh*a/2)*2:min(ih\\,{0})", maxHeightParam)); + filters.Add(string.Format("scale=trunc(oh*a/2)*2:min(max(iw/dar\\,ih)\\,{0})", maxHeightParam)); } } diff --git a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs index aaa5593b48..6bf414dfa4 100644 --- a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs @@ -978,7 +978,7 @@ namespace MediaBrowser.MediaEncoding.Encoder { var maxHeightParam = request.MaxHeight.Value.ToString(UsCulture); - filters.Add(string.Format("scale=trunc(oh*a/2)*2:min(ih\\,{0})", maxHeightParam)); + filters.Add(string.Format("scale=trunc(oh*a/2)*2:min(max(iw/dar\\,ih)\\,{0})", maxHeightParam)); } } -- cgit v1.2.3