or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

data-structures.mdimage-processing.mdindex.mdqrcode-support.mdreading-decoding.mdresult-processing.mdwriting-encoding.md
tile.json

tessl/maven-com-google-zxing--core

Core barcode encoding/decoding library supporting multiple 1D and 2D barcode formats including QR Code, Data Matrix, Aztec, PDF417, and UPC/EAN.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
mavenpkg:maven/com.google.zxing/core@3.5.x

To install, run

npx @tessl/cli install tessl/maven-com-google-zxing--core@3.5.0

index.mddocs/

ZXing Core Library

ZXing (Zebra Crossing) is a comprehensive open-source, multi-format 1D/2D barcode image processing library implemented in Java. The core module provides the fundamental barcode encoding and decoding functionality supporting a wide range of barcode formats including QR Code, Data Matrix, Aztec, PDF417, MaxiCode, and all major 1D formats like UPC/EAN and Code 128.

Package Information

  • Package Name: core
  • Package Type: maven
  • Group ID: com.google.zxing
  • Language: Java
  • Installation: implementation 'com.google.zxing:core:3.5.3' (Gradle) or <dependency><groupId>com.google.zxing</groupId><artifactId>core</artifactId><version>3.5.3</version></dependency> (Maven)

Core Imports

import com.google.zxing.*;
import com.google.zxing.common.*;

For specific formats:

import com.google.zxing.qrcode.QRCodeReader;
import com.google.zxing.qrcode.QRCodeWriter;
import com.google.zxing.datamatrix.DataMatrixReader;
import com.google.zxing.pdf417.PDF417Reader;

Basic Usage

Decoding Barcodes

import com.google.zxing.*;
import com.google.zxing.common.HybridBinarizer;

// Create a luminance source from your image data
LuminanceSource source = new RGBLuminanceSource(width, height, pixels);

// Convert to binary bitmap
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));

// Decode the barcode
MultiFormatReader reader = new MultiFormatReader();
Result result = reader.decode(bitmap);

// Get the decoded text
String text = result.getText();
BarcodeFormat format = result.getBarcodeFormat();

Encoding Barcodes

import com.google.zxing.*;
import com.google.zxing.common.BitMatrix;

// Create a writer
MultiFormatWriter writer = new MultiFormatWriter();

// Encode content as QR code
BitMatrix bitMatrix = writer.encode(
    "Hello World", 
    BarcodeFormat.QR_CODE, 
    300, 
    300
);

// Convert BitMatrix to image (implementation dependent)

Architecture

ZXing Core is built around several key architectural components:

  • Reader/Writer Interfaces: Primary abstractions for decoding and encoding operations
  • Multi-Format Support: MultiFormatReader and MultiFormatWriter provide unified entry points that delegate to format-specific implementations
  • Image Processing Pipeline: LuminanceSourceBinarizerBinaryBitmap for image data processing
  • Result Framework: Structured result objects with metadata and extensible parsing for different data types
  • Format-Specific Packages: Dedicated implementations for each barcode format (QR Code, Data Matrix, etc.)
  • Common Utilities: Shared data structures, error correction, and mathematical utilities

Capabilities

Core Reading Interface

Primary interface for barcode decoding operations with support for hints and multi-format detection.

public interface Reader {
    Result decode(BinaryBitmap image) throws NotFoundException, ChecksumException, FormatException;
    Result decode(BinaryBitmap image, Map<DecodeHintType,?> hints) throws NotFoundException, ChecksumException, FormatException;
    void reset();
}

public final class MultiFormatReader implements Reader {
    public Result decodeWithState(BinaryBitmap image) throws NotFoundException;
    public void setHints(Map<DecodeHintType,?> hints);
}

Reading and Decoding

Core Writing Interface

Primary interface for barcode encoding operations with format-specific delegation and configuration options.

public interface Writer {
    BitMatrix encode(String contents, BarcodeFormat format, int width, int height) throws WriterException;
    BitMatrix encode(String contents, BarcodeFormat format, int width, int height, Map<EncodeHintType,?> hints) throws WriterException;
}

public final class MultiFormatWriter implements Writer {
    // Supports: QR_CODE, DATA_MATRIX, AZTEC, PDF_417, CODE_128, CODE_39, CODE_93, 
    // EAN_8, EAN_13, UPC_A, UPC_E, ITF, CODABAR
}

Writing and Encoding

Image Processing

Comprehensive image processing pipeline for converting various image formats to binary representations suitable for barcode detection.

public abstract class LuminanceSource {
    public abstract byte[] getRow(int y, byte[] row);
    public abstract byte[] getMatrix();
    public abstract int getWidth();
    public abstract int getHeight();
    public LuminanceSource crop(int left, int top, int width, int height);
    public LuminanceSource rotateCounterClockwise();
}

public final class BinaryBitmap {
    public BinaryBitmap(Binarizer binarizer);
    public int getWidth();
    public int getHeight();
    public BitArray getBlackRow(int y, BitArray row) throws NotFoundException;
    public BitMatrix getBlackMatrix() throws NotFoundException;
    public boolean isCropSupported();
    public BinaryBitmap crop(int left, int top, int width, int height);
    public boolean isRotateSupported();
    public BinaryBitmap rotateCounterClockwise();
    public BinaryBitmap rotateCounterClockwise45();
}

Image Processing

Result Processing

Structured result handling with metadata extraction and parsing capabilities for different barcode content types.

public final class Result {
    public Result(String text, byte[] rawBytes, ResultPoint[] resultPoints, BarcodeFormat format);
    public Result(String text, byte[] rawBytes, ResultPoint[] resultPoints, BarcodeFormat format, long timestamp);
    public Result(String text, byte[] rawBytes, int numBits, ResultPoint[] resultPoints, BarcodeFormat format, long timestamp);
    public String getText();
    public byte[] getRawBytes();
    public int getNumBits();
    public ResultPoint[] getResultPoints();
    public BarcodeFormat getBarcodeFormat();
    public Map<ResultMetadataType,Object> getResultMetadata();
    public long getTimestamp();
    public void putMetadata(ResultMetadataType type, Object value);
    public void putAllMetadata(Map<ResultMetadataType,Object> metadata);
    public void addResultPoints(ResultPoint[] newPoints);
}

public abstract class ParsedResult {
    public abstract ParsedResultType getType();
    public abstract String getDisplayResult();
}

Result Processing

Data Structures

Core data structures for bit manipulation, matrix operations, and geometric transformations used throughout the library.

public final class BitMatrix {
    public BitMatrix(int width, int height);
    public boolean get(int x, int y);
    public void set(int x, int y);
    public BitArray getRow(int y, BitArray row);
}

public final class BitArray {
    public BitArray();
    public BitArray(int size);
    public boolean get(int i);
    public void set(int i);
    public int getNextSet(int from);
}

Data Structures

QR Code Support

Complete QR Code implementation with encoding, decoding, error correction, and version management.

public final class QRCodeReader implements Reader {
    // QR Code specific decoding
}

public final class QRCodeWriter implements Writer {
    // QR Code specific encoding
}

QR Code Support

Additional Format Support

ZXing Core provides comprehensive support for additional barcode formats beyond QR codes:

  • Data Matrix: 2D barcodes with configurable symbol sizes and advanced encoding modes
  • 1D Barcodes: Complete support for UPC/EAN family, Code family (39, 93, 128), ITF, Codabar, and RSS formats
  • Other 2D Formats: Aztec, PDF417, and MaxiCode with format-specific readers and writers
  • Error Correction: Reed-Solomon implementation for robust data recovery across all 2D formats

All formats are accessible through the MultiFormatReader and MultiFormatWriter classes, with format-specific classes available in their respective packages (e.g., com.google.zxing.datamatrix, com.google.zxing.oned) for advanced configuration.

Core Types

public enum BarcodeFormat {
    // 1D formats
    CODABAR, CODE_39, CODE_93, CODE_128, EAN_8, EAN_13, ITF, UPC_A, UPC_E, 
    UPC_EAN_EXTENSION, RSS_14, RSS_EXPANDED,
    // 2D formats  
    AZTEC, DATA_MATRIX, MAXICODE, PDF_417, QR_CODE
}

public enum DecodeHintType {
    OTHER, PURE_BARCODE, POSSIBLE_FORMATS, TRY_HARDER, CHARACTER_SET, ALLOWED_LENGTHS,
    ASSUME_CODE_39_CHECK_DIGIT, ASSUME_GS1, RETURN_CODABAR_START_END,
    NEED_RESULT_POINT_CALLBACK, ALLOWED_EAN_EXTENSIONS, ALSO_INVERTED
}

public enum EncodeHintType {
    ERROR_CORRECTION, CHARACTER_SET, DATA_MATRIX_SHAPE, MARGIN,
    PDF417_COMPACT, AZTEC_LAYERS, QR_VERSION, QR_MASK_PATTERN, GS1_FORMAT
}

public enum ResultMetadataType {
    ORIENTATION, BYTE_SEGMENTS, ERROR_CORRECTION_LEVEL, ERRORS_CORRECTED,
    ISSUE_NUMBER, SUGGESTED_PRICE, POSSIBLE_COUNTRY, UPC_EAN_EXTENSION,
    PDF417_EXTRA_METADATA, STRUCTURED_APPEND_SEQUENCE, SYMBOLOGY_IDENTIFIER
}

public enum ParsedResultType {
    ADDRESSBOOK, EMAIL_ADDRESS, PRODUCT, URI, TEXT, GEO, TEL, SMS, 
    CALENDAR, WIFI, ISBN, VIN
}

// Exception hierarchy
public abstract class ReaderException extends Exception;
public final class ChecksumException extends ReaderException;
public final class FormatException extends ReaderException;
public final class NotFoundException extends ReaderException;
public final class WriterException extends Exception;