BarcodeReader.ImageSharp 2.0.1

dotnet add package BarcodeReader.ImageSharp --version 2.0.1                
NuGet\Install-Package BarcodeReader.ImageSharp -Version 2.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BarcodeReader.ImageSharp" Version="2.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BarcodeReader.ImageSharp --version 2.0.1                
#r "nuget: BarcodeReader.ImageSharp, 2.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install BarcodeReader.ImageSharp as a Cake Addin
#addin nuget:?package=BarcodeReader.ImageSharp&version=2.0.1

// Install BarcodeReader.ImageSharp as a Cake Tool
#tool nuget:?package=BarcodeReader.ImageSharp&version=2.0.1                

BarcodeReader.ImageSharp

Nuget Downloads Build

A barcode reader compatible with SixLabors.ImageSharp using ZXing. Trying to get off System.Drawing.Common.

I created this library specifically to use with blazor but you can totally use this for other use cases!

Features

This is a basic facade-library for the ZXing.Bindings.ImageSharp.V2 library which uses SixLabors.ImageSharp.

Included Features are:

  • Barcode reading functionality that supports all ImageSharp image formats
  • Decode Barcodes synchronously and asynchronously
  • Get rich results from the decoding
  • Fired events for better support in decoding loops

.NET Support

The library supports a vast majority of up-to-date .NET versions:

  • .NET Standard 2.0+
  • .NET Framework 4.7.2
  • .NET Core 3.1+
  • .NET 5+

Installation

There are two ways to add the BarcodeReader.ImageSharp library to your projects:

  1. Open the command line and go into the directoy where your .csproj file is located, then execute this command:
dotnet add package BlazorCameraStreamer
  1. Or add it in the GUI of Visual Studio 20XX:
    ToolsNuget Package ManagerManage Nuget Packages for Solution...

Then add the following using to your C# files:

using BarcodeReader.ImageSharp;

And depending on your code, you probably need one or more of the following usings:

using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Formats.Png;

How to Use

In the following code we use one of ImageSharps pixelformats IPixel<Rgba32> which we will use to load PNG images from files.

string path = @"C:\images\qrcode.png";

// first we need to Load a image
Image<Rgba32> image = Image.Load<Rgba32>(path);

// then we create a new BarcodeReader object
BarcodeReader<Rgba32> reader = new BarcodeReader<Rgba32>(types: ZXing.BarcodeFormat.QR_CODE);

// then we can get a result by decoding
BarcodeResult<Rgba32> result = await reader.DecodeAsync(image);

// then we can print out the result
if (result.Status == Status.Found)
{
    Console.WriteLine(result.Value);
}
else if (result.Status == Status.NotFound)
{
    Console.WriteLine(result.Message);
}
else if (result.Status == Status.Error)
{
    Console.WriteLine("An error occured while decoding barcode");
}

If you're using the reader in a while loop, you can use the DetectedBarcode event to only recieve BarcodeResults with a Status.Found:

// add handler to event
reader.DetectedBarcode += Recieved_Handler;

// infite loop for demonstration purposes
while (true)
{
    // recieve image from any method (not defined here)
    Image<Rgba32> img = GetNewImage();
    
    // decode the image. DetectedBarcode events are fired when a barcode could be found
    await reader.DecodeAsync(img);
}

// handler which is called when a barcode could be detected by any Decode call
void Recieved_Handler(object sender, BarcodeEventArgs<Rgba32> e) { /* Do something with the result */ }
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 is compatible.  net48 is compatible.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.1 27,762 6/26/2022
2.0.0 423 6/24/2022
1.1.1 496 6/23/2022 1.1.1 is deprecated because it has critical bugs.
1.0.0 1,429 10/27/2021 1.0.0 is deprecated because it has critical bugs.

README added to NuGet package.