April 11, 2025 | blog, Tutorial

How to Read Data Matrix Code Online


Data Matrix codes are widely used in industries like manufacturing, logistics, and healthcare for tracking and identification. To reliably decode them, you need a high-performance Data Matrix code reader, and GdPicture SDK delivers exactly that for .NET developers.

In this post, you’ll learn how to read Data Matrix barcodes from images using the GdPicture barcode engine with minimal setup.

Why Choose GdPicture for Data Matrix Code Reading?

GdPicture offers a high-speed, reliable barcode recognition engine with full support for 2D symbologies like Data Matrix. Its .NET SDK includes:

  • Support for all major image formats (JPG, PNG, BMP, TIFF, PDF raster)
  • Fast or high-accuracy scanning modes (BestSpeed or BestQuality)
  • Multi-barcode detection per image
  • Metadata extraction: size, structure, skew
  • Access to decoded text or raw byte values

How to Read a Data Matrix Code in C#

Here’s how to implement a Data Matrix scanner using GdPictureImaging in C#:

using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
    int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);

    int expectedBarcodes = 0; // 0 = detect all
    var mode = BarcodeDataMatrixReaderScanMode.BestSpeed;

    gdpictureImaging.BarcodeDataMatrixReaderDoScan(imageID, mode, expectedBarcodes);

    int barcodesFound = gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeCount();

    for (int i = 1; i <= barcodesFound; i++)
    {
        string value = gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeValue(i);
        int rows = gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeRows(i);
        int columns = gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeColumns(i);

        Console.WriteLine($"Data Matrix {i}: {value} ({rows}x{columns})");
    }

    gdpictureImaging.BarcodeDataMatrixReaderClear();
    gdpictureImaging.ReleaseGdPictureImage(imageID);
}

🔗 GdPicture API Reference

This snippet scans an image, locates all Data Matrix barcodes, and extracts decoded values and metadata.

Advanced Capabilities

  • Detect barcodes regardless of orientation or skew
  • Extract corner coordinates for position tracking
  • Access raw bytes for binary data use cases
  • Tune scan mode for speed vs. accuracy
  • Handle multi-barcode images for forms or packaging

Common Use Cases

  • Manufacturing – Identify products, parts, or lots
  • Logistics – Read container or shipment labels
  • Healthcare – Scan medication and sample barcodes
  • Business processes – Automate form ID or batch scanning

Conclusion

The GdPicture SDK gives .NET developers a powerful and flexible toolset for reading Data Matrix codes in real-world documents and images. Whether you’re processing a single barcode or building a bulk workflow, GdPicture is ready to scale with you.

Have barcode scanning requirements?

Contact our sales team to learn how GdPicture can streamline your document or labeling system.

FAQ

1. What is a Data Matrix code?

A Data Matrix is a 2D barcode made up of black and white cells arranged in a square or rectangular pattern. It’s designed for small-item labeling and high-density data encoding, with built-in error correction (ECC 200).

2. How do I read a Data Matrix code using GdPicture?

You can use the GdPictureImaging class to load an image and run the BarcodeDataMatrixReaderDoScan() method. The SDK will return the number of codes found and allow you to extract decoded values, row/column structure, and barcode positions.

3. Can GdPicture read multiple Data Matrix codes in one image?

Yes. Set the expectedBarcodes parameter to 0 when scanning. This instructs the SDK to detect all Data Matrix codes present in the image, regardless of how many are there.

4. What scan modes are available for Data Matrix reading?

GdPicture offers two modes:

  • BestSpeed: Prioritizes scanning performance for clean images
  • BestQuality: Improves detection on low-resolution, noisy, or skewed images
    Choose the mode based on your accuracy and speed requirements.

5. What metadata can I extract from a Data Matrix code?

In addition to the decoded value, GdPicture lets you retrieve:

  • Rows and columns (matrix size)
  • Corner coordinates
  • Raw byte data (if the symbol encodes binary content)
    This is useful for validation, visualization, and positioning logic in image workflows.


Tags: