# BPMDeviceLib.Barcode

`BPMDeviceLib.Barcode` is a pure C# barcode scanning library for .NET 6+.

## Goals

- Pure C#
- No external runtime dependencies
- No Blazor dependency
- No `System.Drawing.Common`
- No ImageSharp
- No SkiaSharp
- No UI framework dependency
- Works on a custom grayscale image abstraction

## Supported formats

Current supported format:

- Code 39

Planned formats:

- EAN-13
- UPC-A
- Code 128

Not supported yet:

- QR Code
- PDF417
- Data Matrix

## Basic usage

```csharp
using BPMDeviceLib.Barcode;
using BPMDeviceLib.Barcode.Abstractions;
using BPMDeviceLib.Barcode.Imaging;

var image = new GrayImage(width, height, grayscalePixels);

var scanner = new BarcodeScanner(new BarcodeScannerOptions
{
    Formats = new[] { BarcodeFormat.Code39 },
    TryHarder = true,
    TryInverted = true
});

BarcodeResult? result = scanner.Scan(image);

if (result is not null)
{
    Console.WriteLine($"Found {result.Format}: {result.Text}");
}
```

## Creating a GrayImage

`GrayImage` expects row-major grayscale bytes:

- `0` = black
- `255` = white

The library does not decode PNG/JPEG files directly. Convert pixels from your image source to grayscale first, then create a `GrayImage`.

## Blazor usage concept

The core library does not access the camera directly.

In Blazor, capture a camera frame or uploaded image, convert RGBA pixels to grayscale bytes, create a `GrayImage`, and pass it to `BarcodeScanner`.

## Running tests

From the repository root:

```bash
dotnet test
```
