Libdmtx.Net
0.7.9-dev
See the version list below for details.
dotnet add package Libdmtx.Net --version 0.7.9-dev
NuGet\Install-Package Libdmtx.Net -Version 0.7.9-dev
<PackageReference Include="Libdmtx.Net" Version="0.7.9-dev" />
<PackageVersion Include="Libdmtx.Net" Version="0.7.9-dev" />
<PackageReference Include="Libdmtx.Net" />
paket add Libdmtx.Net --version 0.7.9-dev
#r "nuget: Libdmtx.Net, 0.7.9-dev"
#:package Libdmtx.Net@0.7.9-dev
#addin nuget:?package=Libdmtx.Net&version=0.7.9-dev&prerelease
#tool nuget:?package=Libdmtx.Net&version=0.7.9-dev&prerelease
Libdmtx.Net — .NET 8/9 Data Matrix Wrapper
Community-maintained .NET wrapper for libdmtx, the open-source C library for encoding and decoding Data Matrix ECC200 barcodes. This is not an official package from the libdmtx project.
Features
- ✅ .NET 8 & .NET 9 support (cross-platform)
- ✅ No System.Drawing dependency — uses raw
byte[]pixel data - ✅ Encode text/bytes → Data Matrix barcode image
- ✅ Decode Data Matrix barcode image → text/bytes
- ✅ Modern C# API with nullable annotations
Quick Start
1. Build the native library
See native/BUILD.md for platform-specific instructions.
After building, copy libdmtx.dll (or .so/.dylib) to your output directory.
2. Add the NuGet reference
<ProjectReference Include="path/to/src/Libdmtx.Net/Libdmtx.Net.csproj" />
3. Encode
using Libdmtx;
byte[] data = Encoding.ASCII.GetBytes("Hello World!");
EncodeResult result = Dmtx.Encode(data, new EncodeOptions
{
ModuleSize = 5,
MarginSize = 2,
});
// result.PixelData contains 24-bit BGR pixels
// result.Width, result.Height give image dimensions
SaveAsBmp(result.PixelData, result.Width, result.Height, "barcode.bmp");
4. Decode
using Libdmtx;
// Load image data as BGR24 byte array
byte[] imageData = File.ReadAllBytes("barcode.raw");
// ... or convert from Bitmap using LockBits ...
DecodeResult[] results = Dmtx.Decode(imageData, width, height, stride);
foreach (var r in results)
{
string text = r.Text; // auto-trims null padding
Console.WriteLine($"Decoded: {text}");
}
Project Structure
dotnet/
├── src/Libdmtx.Net/ # Class library
│ ├── Dmtx.cs # Main entry point (static API)
│ ├── DmtxImage.cs # Native image handle wrapper
│ ├── DmtxException.cs # Custom exceptions
│ ├── Options/ # Encode/Decode options
│ ├── Results/ # Encode/Decode results
│ └── Interop/
│ ├── NativeMethods.cs # DllImport declarations
│ ├── NativeEnums.cs # C# enums matching libdmtx defines
│ └── NativeStructs.cs # C# structs for native types
├── samples/Libdmtx.Demo/ # Console demo app
└── native/BUILD.md # Native library build guide
API Overview
Dmtx.Encode(byte[] data, EncodeOptions? options)
Encodes data into a Data Matrix barcode. Returns EncodeResult with raw pixel data.
Dmtx.EncodeString(string text, EncodeOptions? options)
Shorthand for encoding ASCII text.
Dmtx.Decode(byte[] pixelData, int width, int height, int stride, DecodeOptions? options)
Decodes one or more Data Matrix symbols from a BGR24 image.
Dmtx.Version
Returns the native libdmtx version string, or null if the library isn't loaded.
Notes
- The library expects 24-bit BGR pixel data (matching libdmtx's native format).
- Input pixel data must remain pinned/rooted during decoding — the wrapper handles this.
- The native DLL must be placed where the runtime can find it (same directory as the .exe, or system PATH).
License
The C# wrapper code in this package is licensed under BSD-2-Clause.
The bundled native library is Copyright © Mike Laughton, Vadim A. Misbakh-Soloviov and others, used under the BSD-2-Clause license (see the libdmtx LICENSE file for full terms).
This is a community-maintained package, not an official libdmtx release.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
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 |
|---|---|---|
| 0.7.9-dev.2 | 136 | 7/29/2026 |
| 0.7.9-dev.1 | 69 | 7/29/2026 |
| 0.7.9-dev | 57 | 7/29/2026 |