From 2be746a68cf3521471963bf7fcdd844a99a61a1d Mon Sep 17 00:00:00 2001 From: Will-Bill Date: Sat, 4 Nov 2023 11:42:54 +0000 Subject: [PATCH] Update target frameworks to only include .NET 6.0 and Upgrade Six Labor packages --- .../MigraDocCore.DocumentObjectModel.csproj | 2 +- .../MigraDocCore.Rendering.csproj | 2 +- .../PdfSharpCore.Charting.csproj | 2 +- PdfSharpCore.Test/CreateSimplePDF.cs | 6 ++++-- PdfSharpCore.Test/PdfSharpCore.Test.csproj | 2 +- PdfSharpCore/PdfSharpCore.csproj | 6 +++--- PdfSharpCore/Utils/ImageSharpImageSource.cs | 18 ++++++++++++------ SampleApp/SampleApp.csproj | 2 +- 8 files changed, 24 insertions(+), 16 deletions(-) diff --git a/MigraDocCore.DocumentObjectModel/MigraDocCore.DocumentObjectModel.csproj b/MigraDocCore.DocumentObjectModel/MigraDocCore.DocumentObjectModel.csproj index f3f17cc0..dd423ee2 100644 --- a/MigraDocCore.DocumentObjectModel/MigraDocCore.DocumentObjectModel.csproj +++ b/MigraDocCore.DocumentObjectModel/MigraDocCore.DocumentObjectModel.csproj @@ -1,6 +1,6 @@  - netstandard2.0;netcoreapp3.1;net5.0;net6.0 + net6.0 false True Stefan Steiger and Contributors diff --git a/MigraDocCore.Rendering/MigraDocCore.Rendering.csproj b/MigraDocCore.Rendering/MigraDocCore.Rendering.csproj index 3666b526..05e47275 100644 --- a/MigraDocCore.Rendering/MigraDocCore.Rendering.csproj +++ b/MigraDocCore.Rendering/MigraDocCore.Rendering.csproj @@ -1,6 +1,6 @@  - netstandard2.0;netcoreapp3.1;net5.0;net6.0 + net6.0 false True Stefan Steiger and Contributors diff --git a/PdfSharpCore.Charting/PdfSharpCore.Charting.csproj b/PdfSharpCore.Charting/PdfSharpCore.Charting.csproj index 83761556..4f71c4ce 100644 --- a/PdfSharpCore.Charting/PdfSharpCore.Charting.csproj +++ b/PdfSharpCore.Charting/PdfSharpCore.Charting.csproj @@ -1,6 +1,6 @@  - netstandard2.0;netcoreapp3.1;net5.0;net6.0 + net6.0 false True Stefan Steiger and Contributors diff --git a/PdfSharpCore.Test/CreateSimplePDF.cs b/PdfSharpCore.Test/CreateSimplePDF.cs index ce9a4d49..8de82615 100644 --- a/PdfSharpCore.Test/CreateSimplePDF.cs +++ b/PdfSharpCore.Test/CreateSimplePDF.cs @@ -88,11 +88,13 @@ public void CreateTestPdfWithImageViaImageSharp() var renderer = XGraphics.FromPdfPage(pageNewRenderer); // Load image for ImageSharp and apply a simple mutation: - var image = Image.Load(PathHelper.GetInstance().GetAssetPath("lenna.png"), out var format); + var image = Image.Load(PathHelper.GetInstance().GetAssetPath("lenna.png")); image.Mutate(ctx => ctx.Grayscale()); + var imageInfo = Image.Identify(PathHelper.GetInstance().GetAssetPath("lenna.png")); + // create XImage from that same ImageSharp image: - var source = ImageSharpImageSource.FromImageSharpImage(image, format); + var source = ImageSharpImageSource.FromImageSharpImage(image, imageInfo.Metadata.DecodedImageFormat); var img = XImage.FromImageSource(source); renderer.DrawImage(img, new XPoint(0, 0)); diff --git a/PdfSharpCore.Test/PdfSharpCore.Test.csproj b/PdfSharpCore.Test/PdfSharpCore.Test.csproj index 5db969bc..c545af2c 100644 --- a/PdfSharpCore.Test/PdfSharpCore.Test.csproj +++ b/PdfSharpCore.Test/PdfSharpCore.Test.csproj @@ -1,7 +1,7 @@ - netcoreapp3.1;net5.0;net6.0 + net6.0 false false diff --git a/PdfSharpCore/PdfSharpCore.csproj b/PdfSharpCore/PdfSharpCore.csproj index 9f8cedfd..f6f8b159 100644 --- a/PdfSharpCore/PdfSharpCore.csproj +++ b/PdfSharpCore/PdfSharpCore.csproj @@ -1,7 +1,7 @@  - netstandard2.0;netcoreapp3.1;net5.0;net6.0 + net6.0 false True Stefan Steiger and Contributors @@ -47,8 +47,8 @@ PdfSharpCore is a partial port of PdfSharp.Xamarin for .NET Core Additionally Mi - - + + diff --git a/PdfSharpCore/Utils/ImageSharpImageSource.cs b/PdfSharpCore/Utils/ImageSharpImageSource.cs index 383863f4..33e67f2d 100644 --- a/PdfSharpCore/Utils/ImageSharpImageSource.cs +++ b/PdfSharpCore/Utils/ImageSharpImageSource.cs @@ -3,6 +3,7 @@ using MigraDocCore.DocumentObjectModel.MigraDoc.DocumentObjectModel.Shapes; using System; using System.IO; +using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats.Bmp; using SixLabors.ImageSharp.Formats.Jpeg; @@ -21,22 +22,27 @@ public static IImageSource FromImageSharpImage(Image image, IImageFormat protected override IImageSource FromBinaryImpl(string name, Func imageSource, int? quality = 75) { - var image = Image.Load(imageSource.Invoke(), out IImageFormat imgFormat); - return new ImageSharpImageSourceImpl(name, image, (int)quality, imgFormat is PngFormat); + var readOnlySpan = imageSource.Invoke(); + var image = Image.Load(readOnlySpan); + var imageInfo = Image.Identify(readOnlySpan); + return new ImageSharpImageSourceImpl(name, image, (int)quality, imageInfo.Metadata.DecodedImageFormat is PngFormat); } protected override IImageSource FromFileImpl(string path, int? quality = 75) { - var image = Image.Load(path, out IImageFormat imgFormat); - return new ImageSharpImageSourceImpl(path, image, (int) quality, imgFormat is PngFormat); + var image = Image.Load(path); + var imageInfo = Image.Identify(path); + return new ImageSharpImageSourceImpl(path, image, (int) quality, imageInfo.Metadata.DecodedImageFormat is PngFormat); } protected override IImageSource FromStreamImpl(string name, Func imageStream, int? quality = 75) { using (var stream = imageStream.Invoke()) { - var image = Image.Load(stream, out IImageFormat imgFormat); - return new ImageSharpImageSourceImpl(name, image, (int)quality, imgFormat is PngFormat); + var image = Image.Load(stream); + var imageInfo = Image.Identify(stream); + + return new ImageSharpImageSourceImpl(name, image, (int)quality, imageInfo.Metadata.DecodedImageFormat is PngFormat); } } diff --git a/SampleApp/SampleApp.csproj b/SampleApp/SampleApp.csproj index 464229b5..1d1eafcc 100644 --- a/SampleApp/SampleApp.csproj +++ b/SampleApp/SampleApp.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp3.1;net5.0;net6.0 + net6.0 false enable enable