Browse Source

add skia error handling

Luke Pulverenti 8 năm trước cách đây
mục cha
commit
bcaf9bd19c
2 tập tin đã thay đổi với 9 bổ sung4 xóa
  1. 4 4
      Emby.Drawing.Skia/SkiaEncoder.cs
  2. 5 0
      Emby.Drawing/ImageProcessor.cs

+ 4 - 4
Emby.Drawing.Skia/SkiaEncoder.cs

@@ -63,15 +63,15 @@ namespace Emby.Drawing.Skia
 
         private void LogVersion()
         {
+            // test an operation that requires the native library
+            SKPMColor.PreMultiply(SKColors.Black);
+
             _logger.Info("SkiaSharp version: " + GetVersion());
         }
 
         public static string GetVersion()
         {
-            using (var bitmap = new SKBitmap())
-            {
-                return typeof(SKBitmap).GetTypeInfo().Assembly.GetName().Version.ToString();
-            }
+            return typeof(SKBitmap).GetTypeInfo().Assembly.GetName().Version.ToString();
         }
 
         private static bool IsWhiteSpace(SKColor color)

+ 5 - 0
Emby.Drawing/ImageProcessor.cs

@@ -410,6 +410,11 @@ namespace Emby.Drawing
             return GetCachePath(ResizedImageCachePath, filename, "." + format.ToString().ToLower());
         }
 
+        public ImageSize GetImageSize(ItemImageInfo info, bool allowSlowMethods)
+        {
+            return GetImageSize(info.Path, info.DateModified, allowSlowMethods);
+        }
+
         public ImageSize GetImageSize(ItemImageInfo info)
         {
             return GetImageSize(info.Path, info.DateModified, false);