Skip to content

Commit

Permalink
Update ImageSharp to 2.1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
huysentruitw committed Jun 13, 2024
1 parent 091e010 commit b736045
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions src/Barcoder.Renderer.Image/Barcoder.Renderer.Image.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net472;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<Title>Barcoder.Renderer.Image</Title>
<Description>Image Renderer for Barcoder (.NET Framework, .NET Standard and .NET Core).</Description>
<Description>Image Renderer for Barcoder (.NET6, .NET8).</Description>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Company>Wouter Huysentruit</Company>
<Version>1.0.0.0</Version>
Expand All @@ -16,7 +16,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="1.0.0-beta14" />
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="2.1.3" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/Barcoder.Renderer.Image/Internal/EanContentRenderer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Numerics;
using System.Numerics;
using SixLabors.Fonts;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Drawing.Processing;
Expand Down Expand Up @@ -68,7 +68,7 @@ private static void RenderWhiteRect(Image<L8> image, int x, int y, int width, in

private static void RenderBlackText(Image<L8> 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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="Moq" Version="4.20.70" />
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="1.0.0-beta14" />
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="2.1.3" />
<PackageReference Include="xunit" Version="2.8.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.1">
<PrivateAssets>all</PrivateAssets>
Expand Down
8 changes: 4 additions & 4 deletions tests/Barcoder.Renderer.Image.Tests/ImageRendererTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand All @@ -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");
}

Expand All @@ -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");
}

Expand All @@ -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");
}

Expand Down

0 comments on commit b736045

Please sign in to comment.