diff --git a/.github/workflows/build-test-publish.yml b/.github/workflows/build-test-publish.yml index 70ddfb2..ca7dffb 100644 --- a/.github/workflows/build-test-publish.yml +++ b/.github/workflows/build-test-publish.yml @@ -14,20 +14,20 @@ jobs: runs-on: windows-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Fetch all history for all tags and branches run: git fetch --prune --unshallow - name: Install GitVersion - uses: gittools/actions/gitversion/setup@v0.9.11 + uses: gittools/actions/gitversion/setup@v1.1.1 with: versionSpec: '5.x' - name: Use GitVersion id: gitversion # step id used as reference for output values - uses: gittools/actions/gitversion/execute@v0.9.11 - - name: Setup .NET 5 + uses: gittools/actions/gitversion/execute@v1.1.1 + - name: Setup .NET 8 uses: actions/setup-dotnet@v1 with: - dotnet-version: 5.0.302 + dotnet-version: '8.x' - name: Install dependencies run: dotnet restore - name: Build diff --git a/README.md b/README.md index 8619f7c..f0b6e41 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,9 @@ Lightweight Barcode Encoding Library for .NET Framework, .NET Standard and .NET Core. Additional packages are available for rendering the generated barcode to SVG or an image. +Please note that the image renderer (`Barcoder.Renderer.Image`) requires .NET6 or .NET8 because of the dependency on `SixLabors.ImageSharp.Drawing` and no longer works for .NET Framework. +However, feel free to create your own renderer with another version or other image generation library. + Code ported from the GO project https://github.com/boombuler/barcode by [Florian Sundermann](https://github.com/boombuler). Supported Barcode Types: @@ -63,7 +66,7 @@ Example for rendering to PNG: ```csharp var barcode = QrEncoder.Encode("Hello World!"); -var renderer = new ImageRenderer(imageFormat: ImageFormat.Png); +var renderer = new ImageRenderer(new ImageRendererOptions { ImageFormat = ImageFormat.Png }); using (var stream = new FileStream("output.png", FileMode.Create)) { diff --git a/src/Barcoder.Renderer.Image/Barcoder.Renderer.Image.csproj b/src/Barcoder.Renderer.Image/Barcoder.Renderer.Image.csproj index 6790125..67b1368 100644 --- a/src/Barcoder.Renderer.Image/Barcoder.Renderer.Image.csproj +++ b/src/Barcoder.Renderer.Image/Barcoder.Renderer.Image.csproj @@ -1,9 +1,9 @@  - net472;netstandard2.0 + net6.0;net8.0 Barcoder.Renderer.Image - Image Renderer for Barcoder (.NET Framework, .NET Standard and .NET Core). + Image Renderer for Barcoder (.NET6, .NET8). true Wouter Huysentruit 1.0.0.0 @@ -16,7 +16,7 @@ - + diff --git a/src/Barcoder.Renderer.Image/Internal/EanContentRenderer.cs b/src/Barcoder.Renderer.Image/Internal/EanContentRenderer.cs index 1985ab0..ab35042 100644 --- a/src/Barcoder.Renderer.Image/Internal/EanContentRenderer.cs +++ b/src/Barcoder.Renderer.Image/Internal/EanContentRenderer.cs @@ -1,4 +1,4 @@ -using System.Numerics; +using System.Numerics; using SixLabors.Fonts; using SixLabors.ImageSharp; using SixLabors.ImageSharp.Drawing.Processing; @@ -68,7 +68,7 @@ private static void RenderWhiteRect(Image image, int x, int y, int width, in private static void RenderBlackText(Image image, string text, float x, float y, Font font) { - var options = new TextOptions(font) + var options = new RichTextOptions(font) { HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, diff --git a/src/Barcoder.Renderer.Svg/Barcoder.Renderer.Svg.csproj b/src/Barcoder.Renderer.Svg/Barcoder.Renderer.Svg.csproj index 262a8b2..52b6486 100644 --- a/src/Barcoder.Renderer.Svg/Barcoder.Renderer.Svg.csproj +++ b/src/Barcoder.Renderer.Svg/Barcoder.Renderer.Svg.csproj @@ -15,7 +15,7 @@ - + diff --git a/tests/Barcoder.Renderer.Image.Tests/Barcoder.Renderer.Image.Tests.csproj b/tests/Barcoder.Renderer.Image.Tests/Barcoder.Renderer.Image.Tests.csproj index 46633a1..dc9376a 100644 --- a/tests/Barcoder.Renderer.Image.Tests/Barcoder.Renderer.Image.Tests.csproj +++ b/tests/Barcoder.Renderer.Image.Tests/Barcoder.Renderer.Image.Tests.csproj @@ -1,18 +1,18 @@  - net5.0 + net8.0 latest false - - - - - - + + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/tests/Barcoder.Renderer.Image.Tests/ImageRendererTests.cs b/tests/Barcoder.Renderer.Image.Tests/ImageRendererTests.cs index 154438b..d1665c8 100644 --- a/tests/Barcoder.Renderer.Image.Tests/ImageRendererTests.cs +++ b/tests/Barcoder.Renderer.Image.Tests/ImageRendererTests.cs @@ -85,7 +85,7 @@ public void Render_ImageFormatBmp_ShouldRenderBmp() // Assert stream.Position = 0; - using var image = ImageSharp.Image.Load(stream, out IImageFormat imageFormat); + IImageFormat imageFormat = ImageSharp.Image.DetectFormat(stream); imageFormat.Name.Should().Be("BMP"); } @@ -102,7 +102,7 @@ public void Render_ImageFormatGif_ShouldRenderGif() // Assert stream.Position = 0; - using var image = ImageSharp.Image.Load(stream, out IImageFormat imageFormat); + IImageFormat imageFormat = ImageSharp.Image.DetectFormat(stream); imageFormat.Name.Should().Be("GIF"); } @@ -119,7 +119,7 @@ public void Render_ImageFormatJpeg_ShouldRenderJpeg() // Assert stream.Position = 0; - using var image = ImageSharp.Image.Load(stream, out IImageFormat imageFormat); + IImageFormat imageFormat = ImageSharp.Image.DetectFormat(stream); imageFormat.Name.Should().Be("JPEG"); } @@ -136,7 +136,7 @@ public void Render_ImageFormatPng_ShouldRenderPng() // Assert stream.Position = 0; - using var image = ImageSharp.Image.Load(stream, out IImageFormat imageFormat); + IImageFormat imageFormat = ImageSharp.Image.DetectFormat(stream); imageFormat.Name.Should().Be("PNG"); } diff --git a/tests/Barcoder.Renderer.Svg.Tests/Barcoder.Renderer.Svg.Tests.csproj b/tests/Barcoder.Renderer.Svg.Tests/Barcoder.Renderer.Svg.Tests.csproj index e9647e7..e245bdb 100644 --- a/tests/Barcoder.Renderer.Svg.Tests/Barcoder.Renderer.Svg.Tests.csproj +++ b/tests/Barcoder.Renderer.Svg.Tests/Barcoder.Renderer.Svg.Tests.csproj @@ -1,7 +1,7 @@ - net5.0 + net8.0 latest false @@ -17,11 +17,11 @@ - - - - - + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/tests/Barcoder.Tests/Barcoder.Tests.csproj b/tests/Barcoder.Tests/Barcoder.Tests.csproj index 1b3079d..783d950 100644 --- a/tests/Barcoder.Tests/Barcoder.Tests.csproj +++ b/tests/Barcoder.Tests/Barcoder.Tests.csproj @@ -1,16 +1,16 @@  - net5.0 + net8.0 latest false - - - - + + + + all runtime; build; native; contentfiles; analyzers