Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update target frameworks to only include .NET 6.0 and Upgrade Six Lab… #405

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>net6.0</TargetFrameworks>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Authors>Stefan Steiger and Contributors</Authors>
Expand Down
2 changes: 1 addition & 1 deletion MigraDocCore.Rendering/MigraDocCore.Rendering.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>net6.0</TargetFrameworks>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Authors>Stefan Steiger and Contributors</Authors>
Expand Down
2 changes: 1 addition & 1 deletion PdfSharpCore.Charting/PdfSharpCore.Charting.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>net6.0</TargetFrameworks>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Authors>Stefan Steiger and Contributors</Authors>
Expand Down
6 changes: 4 additions & 2 deletions PdfSharpCore.Test/CreateSimplePDF.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Rgb24>(PathHelper.GetInstance().GetAssetPath("lenna.png"), out var format);
var image = Image.Load<Rgb24>(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<Rgb24>.FromImageSharpImage(image, format);
var source = ImageSharpImageSource<Rgb24>.FromImageSharpImage(image, imageInfo.Metadata.DecodedImageFormat);
var img = XImage.FromImageSource(source);

renderer.DrawImage(img, new XPoint(0, 0));
Expand Down
2 changes: 1 addition & 1 deletion PdfSharpCore.Test/PdfSharpCore.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>net6.0</TargetFrameworks>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
Expand Down
6 changes: 3 additions & 3 deletions PdfSharpCore/PdfSharpCore.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>net6.0</TargetFrameworks>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Authors>Stefan Steiger and Contributors</Authors>
Expand Down Expand Up @@ -47,8 +47,8 @@ PdfSharpCore is a partial port of PdfSharp.Xamarin for .NET Core Additionally Mi
</ItemGroup>
<ItemGroup>
<PackageReference Include="SharpZipLib" Version="1.3.3" />
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.4" />
<PackageReference Include="SixLabors.Fonts" Version="1.0.0-beta17" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.0.2" />
<PackageReference Include="SixLabors.Fonts" Version="2.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
18 changes: 12 additions & 6 deletions PdfSharpCore/Utils/ImageSharpImageSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -21,22 +22,27 @@ public static IImageSource FromImageSharpImage(Image<TPixel> image, IImageFormat

protected override IImageSource FromBinaryImpl(string name, Func<byte[]> imageSource, int? quality = 75)
{
var image = Image.Load<TPixel>(imageSource.Invoke(), out IImageFormat imgFormat);
return new ImageSharpImageSourceImpl<TPixel>(name, image, (int)quality, imgFormat is PngFormat);
var readOnlySpan = imageSource.Invoke();
var image = Image.Load<TPixel>(readOnlySpan);
var imageInfo = Image.Identify(readOnlySpan);
return new ImageSharpImageSourceImpl<TPixel>(name, image, (int)quality, imageInfo.Metadata.DecodedImageFormat is PngFormat);
}

protected override IImageSource FromFileImpl(string path, int? quality = 75)
{
var image = Image.Load<TPixel>(path, out IImageFormat imgFormat);
return new ImageSharpImageSourceImpl<TPixel>(path, image, (int) quality, imgFormat is PngFormat);
var image = Image.Load<TPixel>(path);
var imageInfo = Image.Identify(path);
return new ImageSharpImageSourceImpl<TPixel>(path, image, (int) quality, imageInfo.Metadata.DecodedImageFormat is PngFormat);
}

protected override IImageSource FromStreamImpl(string name, Func<Stream> imageStream, int? quality = 75)
{
using (var stream = imageStream.Invoke())
{
var image = Image.Load<TPixel>(stream, out IImageFormat imgFormat);
return new ImageSharpImageSourceImpl<TPixel>(name, image, (int)quality, imgFormat is PngFormat);
var image = Image.Load<TPixel>(stream);
var imageInfo = Image.Identify(stream);

return new ImageSharpImageSourceImpl<TPixel>(name, image, (int)quality, imageInfo.Metadata.DecodedImageFormat is PngFormat);
}
}

Expand Down
2 changes: 1 addition & 1 deletion SampleApp/SampleApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>net6.0</TargetFrameworks>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand Down