Browse Source

Magick.NET 14.0.0

Ruben 1 year ago
parent
commit
146aa81dc1

+ 2 - 2
src/PicView.Avalonia/Converters/ConversionHelper.cs

@@ -26,7 +26,7 @@ internal static class ConversionHelper
             return false;
         }
 
-        return await SaveImageFileHelper.ResizeImageAsync(fileInfo, (int)width, 0).ConfigureAwait(false);
+        return await SaveImageFileHelper.ResizeImageAsync(fileInfo, (uint)width, 0).ConfigureAwait(false);
     }
 
     internal static async Task<bool> ResizeByHeight(FileInfo fileInfo, double height)
@@ -36,7 +36,7 @@ internal static class ConversionHelper
             return false;
         }
 
-        return await SaveImageFileHelper.ResizeImageAsync(fileInfo, 0, (int)height).ConfigureAwait(false);
+        return await SaveImageFileHelper.ResizeImageAsync(fileInfo, 0, (uint)height).ConfigureAwait(false);
     }
 
     internal static async Task<string> ConvertTask(FileInfo fileInfo, int selectedIndex)

+ 2 - 2
src/PicView.Avalonia/FileSystem/FilePickerHelper.cs

@@ -115,8 +115,8 @@ public static class FilePickerHelper
                         throw new ArgumentOutOfRangeException();
                     }
                     var stream = new FileStream(path, FileMode.Create);
-                    var quality = 100;
-                    bitmap.Save(stream, quality);
+                    const uint quality = 100;
+                    bitmap.Save(stream, (int)quality);
                     await stream.DisposeAsync();
                     var ext = Path.GetExtension(path);
                     if (ext != ".jpg" || ext != ".jpeg" || ext != ".png" || ext != ".bmp" || vm.RotationAngle != 0)

+ 1 - 1
src/PicView.Avalonia/Gallery/GalleryFunctions.cs

@@ -302,7 +302,7 @@ public static class GalleryFunctions
          }
 
          GalleryItem? galleryItem;
-         var imageModel = await ImageHelper.GetImageModelAsync(fileInfo, true, (int)vm.GetGalleryItemHeight);
+         var imageModel = await ImageHelper.GetImageModelAsync(fileInfo, true, (uint)vm.GetGalleryItemHeight);
          var galleryThumbInfo = GalleryThumbInfo.GalleryThumbHolder.GetThumbData(fileInfo);
          try
          {

+ 1 - 1
src/PicView.Avalonia/Gallery/GalleryLoad.cs

@@ -175,7 +175,7 @@ public static class GalleryLoad
                 }
 
                 var thumbImageModel = await ImageHelper.GetImageModelAsync(fileInfos[i], isThumb: true,
-                    (int)galleryItemSize);
+                    (uint)galleryItemSize);
                 var thumbData = GalleryThumbInfo.GalleryThumbHolder.GetThumbData(fileInfos[i]);
 
                 await Dispatcher.UIThread.InvokeAsync(() =>

+ 8 - 8
src/PicView.Avalonia/ImageHandling/ImageHelper.cs

@@ -12,7 +12,7 @@ public static class ImageHelper
 {
     #region Image Handling
     
-    public static async Task<ImageModel?> GetImageModelAsync(FileInfo fileInfo, bool isThumb = false, int height = 0)
+    public static async Task<ImageModel?> GetImageModelAsync(FileInfo fileInfo, bool isThumb = false, uint height = 0)
     {
         return await Task.Run(async () =>
         {
@@ -150,7 +150,7 @@ public static class ImageHelper
         Add(fs, imageModel);
     }
 
-    private static async Task AddDefaultImageAsync(FileInfo fileInfo, ImageModel imageModel, bool isThumb, int height)
+    private static async Task AddDefaultImageAsync(FileInfo fileInfo, ImageModel imageModel, bool isThumb, uint height)
     {
         if (isThumb)
         {
@@ -202,8 +202,8 @@ public static class ImageHelper
     {
         var svg = new MagickImage();
         svg.Ping(fileInfo.FullName);
-        imageModel.PixelWidth = svg.Width;
-        imageModel.PixelHeight = svg.Height;
+        imageModel.PixelWidth = (int)svg.Width;
+        imageModel.PixelHeight = (int)svg.Height;
         imageModel.ImageType = ImageType.Svg;
         imageModel.Image = fileInfo.FullName;
     }
@@ -212,7 +212,7 @@ public static class ImageHelper
 
     #region Base64
 
-    private static async Task AddBase64ImageAsync(FileInfo fileInfo, ImageModel imageModel, bool isThumb, int height)
+    private static async Task AddBase64ImageAsync(FileInfo fileInfo, ImageModel imageModel, bool isThumb, uint height)
     {
         using var magickImage = await ImageDecoder.Base64ToMagickImage(fileInfo.FullName).ConfigureAwait(false);
         using var b64Stream = new MemoryStream();
@@ -232,7 +232,7 @@ public static class ImageHelper
     
     #region Thumbnail
 
-    public static async Task<Bitmap?> GetThumbAsync(string path, int height, FileInfo? fileInfo = null)
+    public static async Task<Bitmap?> GetThumbAsync(string path, uint height, FileInfo? fileInfo = null)
     {
         try
         {
@@ -259,7 +259,7 @@ public static class ImageHelper
         }
     }
     
-    private static async Task AddThumbAsync(FileInfo fileInfo, ImageModel imageModel, int height)
+    private static async Task AddThumbAsync(FileInfo fileInfo, ImageModel imageModel, uint height)
     {
         var thumb = await GetThumbAsync(fileInfo.FullName, height, fileInfo).ConfigureAwait(false);
         imageModel.Image = thumb;
@@ -268,7 +268,7 @@ public static class ImageHelper
         imageModel.ImageType = ImageType.Bitmap;
     }
 
-    private static async Task<Bitmap> CreateThumbAsync(IMagickImage magick, string path, int height, FileInfo? fileInfo = null)
+    private static async Task<Bitmap> CreateThumbAsync(IMagickImage magick, string path, uint height, FileInfo? fileInfo = null)
     {
         fileInfo ??= new FileInfo(path);
         await using var fileStream = new FileStream(path, FileMode.Open, FileAccess.Read,

+ 2 - 2
src/PicView.Avalonia/Navigation/NavigationHelper.cs

@@ -448,8 +448,8 @@ public static class NavigationHelper
             magickImage.Ping(path);
             vm.ImageSource = source;
             vm.ImageType = ImageType.Svg;
-            width = magickImage.Width;
-            height = magickImage.Height;
+            width = (int)magickImage.Width;
+            height = (int)magickImage.Height;
         }
         else
         {

+ 1 - 1
src/PicView.Avalonia/PicView.Avalonia.csproj

@@ -66,7 +66,7 @@
     <!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
     <PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.2.0-beta1" />
     <PackageReference Include="Avalonia.Svg.Skia" Version="11.1.0.1" />
-    <PackageReference Include="Magick.NET-Q8-OpenMP-x64" Version="13.10.0" />
+    <PackageReference Include="Magick.NET-Q8-OpenMP-x64" Version="14.0.0" />
   </ItemGroup>
 
   <ItemGroup>

+ 3 - 3
src/PicView.Core/ImageDecoding/SaveImageFileHelper.cs

@@ -17,8 +17,8 @@ public static class SaveImageFileHelper
     /// <param name="ext">The file extension of the output image.</param>
     /// <param name="rotationAngle">The angle to rotate the image, in degrees.</param>
     /// <returns>True if the image is saved successfully; otherwise, false.</returns>
-    public static async Task<bool> SaveImageAsync(Stream? stream, string? path, string? destination = null, int? width = null,
-        int? height = null, int? quality = null, string? ext = null, double? rotationAngle = null)
+    public static async Task<bool> SaveImageAsync(Stream? stream, string? path, string? destination = null, uint? width = null,
+        uint? height = null, uint? quality = null, string? ext = null, double? rotationAngle = null)
     {
         try
         {
@@ -107,7 +107,7 @@ public static class SaveImageFileHelper
     /// <param name="compress">Indicates whether to compress the image.</param>
     /// <param name="ext">The file extension of the output image.</param>
     /// <returns>True if the image is resized and saved successfully; otherwise, false.</returns>
-    public static async Task<bool> ResizeImageAsync(FileInfo fileInfo, int width, int height, int quality = 100,
+    public static async Task<bool> ResizeImageAsync(FileInfo fileInfo, uint width, uint height, uint quality = 100,
         Percentage? percentage = null, string? destination = null, bool? compress = null, string? ext = null)
     {
         if (fileInfo.Exists == false)

+ 1 - 1
src/PicView.Core/PicView.Core.csproj

@@ -24,7 +24,7 @@
   </PropertyGroup>
 
   <ItemGroup>
-    <PackageReference Include="Magick.NET-Q8-OpenMP-x64" Version="13.10.0" />
+    <PackageReference Include="Magick.NET-Q8-OpenMP-x64" Version="14.0.0" />
     <PackageReference Include="SharpCompress" Version="0.38.0" />
   </ItemGroup>