Barcode2DDecoder Class
Reads the data of Data Matrix (ECC 200), PDF417 and Aztec symbols from their modules, with error correction.
public static class Barcode2DDecoderRemarks
The decoder works on modules, not on pixels. To read the symbols of an image, use the ReadBarcodes2D methods of the Meziantou.Framework.Imaging.Barcodes package, which locate the symbols and sample their modules.
A Data Matrix or Aztec symbol can be in any orientation, mirrored included: the decoder finds it from the finder pattern. The rows of a PDF417 symbol can be read from either side, and each row of the symbol can span several rows of the matrix, as Barcode2D draws them.
Methods
| Name | Description |
|---|---|
| Decode(Barcode2D) | Reads the data of a symbol. |
| Decode(bool[,], Barcode2DType) | Reads the data of a symbol from its modules. |
| TryDecode(bool[,], Barcode2DType, Barcode2DDecodeResult?) | Tries to read the data of a symbol from its modules. |
Decode overloads
Decode(Barcode2D)
Barcode2DDecoder.csReads the data of a symbol.
public static Barcode2DDecodeResult Decode(Barcode2D barcode)Parameters
barcodeBarcode2D- The symbol.
Returns
Barcode2DDecodeResult The content of the symbol.
Exceptions
ArgumentNullExceptionbarcodeisnull.
Example
var dataMatrix = Barcode2D.CreateDataMatrix("https://www.meziantou.net");
var result = Barcode2DDecoder.Decode(dataMatrix);
Assert.Equal("https://www.meziantou.net", result.Text);
Assert.Equal(Barcode2DType.DataMatrix, result.Type);Decode(bool[,], Barcode2DType)
Barcode2DDecoder.csReads the data of a symbol from its modules.
public static Barcode2DDecodeResult Decode(bool[,] modules, Barcode2DType type)Parameters
modulesbool[,]- The modules,
truefor dark, indexed by row then column, without quiet zone. typeBarcode2DType- The type of the symbol.
Returns
Barcode2DDecodeResult The content of the symbol.
Exceptions
ArgumentNullExceptionmodulesisnull.ArgumentOutOfRangeExceptiontypeis not a value ofBarcode2DType.FormatException- The modules are not a symbol of the type, or have more errors than the error correction can fix.
TryDecode(bool[,], Barcode2DType, Barcode2DDecodeResult?)
Barcode2DDecoder.csTries to read the data of a symbol from its modules.
public static bool TryDecode(bool[,] modules, Barcode2DType type, out Barcode2DDecodeResult? result)Parameters
modulesbool[,]- The modules,
truefor dark, indexed by row then column, without quiet zone. typeBarcode2DType- The type of the symbol.
resultBarcode2DDecodeResult?- When this method returns
true, the content of the symbol.
Returns
bool true if the modules are a symbol that could be read; otherwise, false.
Exceptions
ArgumentNullExceptionmodulesisnull.ArgumentOutOfRangeExceptiontypeis not a value ofBarcode2DType.