Table of Contents

Class MatrixUtil

Namespace
ZXing.QrCode.Internal
Assembly
zxing.dll
public static class MatrixUtil
Inheritance
MatrixUtil
Inherited Members

Methods

buildMatrix(BitArray, ErrorCorrectionLevel, Version, int, ByteMatrix)

Build 2D matrix of QR Code from "dataBits" with "ecLevel", "version" and "getMaskPattern". On success, store the result in "matrix" and return true.

public static void buildMatrix(BitArray dataBits, ErrorCorrectionLevel ecLevel, Version version, int maskPattern, ByteMatrix matrix)

Parameters

dataBits BitArray

The data bits.

ecLevel ErrorCorrectionLevel

The ec level.

version Version

The version.

maskPattern int

The mask pattern.

matrix ByteMatrix

The matrix.

calculateBCHCode(int, int)

Calculate BCH (Bose-Chaudhuri-Hocquenghem) code for "value" using polynomial "poly". The BCH code is used for encoding type information and version information. Example: Calculation of version information of 7. f(x) is created from 7.

  • 7 = 000111 in 6 bits
  • f(x) = x^2 + x^2 + x^1 g(x) is given by the standard (p. 67)
  • g(x) = x^12 + x^11 + x^10 + x^9 + x^8 + x^5 + x^2 + 1 Multiply f(x) by x^(18 - 6)
  • f'(x) = f(x) * x^(18 - 6)
  • f'(x) = x^14 + x^13 + x^12 Calculate the remainder of f'(x) / g(x) x^2 __________________________________________________ g(x) )x^14 + x^13 + x^12 x^14 + x^13 + x^12 + x^11 + x^10 + x^7 + x^4 + x^2 -------------------------------------------------- x^11 + x^10 + x^7 + x^4 + x^2

The remainder is x^11 + x^10 + x^7 + x^4 + x^2 Encode it in binary: 110010010100 The return value is 0xc94 (1100 1001 0100)

Since all coefficients in the polynomials are 1 or 0, we can do the calculation by bit operations. We don't care if coefficients are positive or negative.

public static int calculateBCHCode(int value, int poly)

Parameters

value int

The value.

poly int

The poly.

Returns

int

clearMatrix(ByteMatrix)

Set all cells to 2. 2 means that the cell is empty (not set yet).

JAVAPORT: We shouldn't need to do this at all. The code should be rewritten to begin encoding with the ByteMatrix initialized all to zero.

public static void clearMatrix(ByteMatrix matrix)

Parameters

matrix ByteMatrix

The matrix.

embedBasicPatterns(Version, ByteMatrix)

Embed basic patterns. On success, modify the matrix and return true. The basic patterns are:

  • Position detection patterns
  • Timing patterns
  • Dark dot at the left bottom corner
  • Position adjustment patterns, if need be
public static void embedBasicPatterns(Version version, ByteMatrix matrix)

Parameters

version Version

The version.

matrix ByteMatrix

The matrix.

embedDataBits(BitArray, int, ByteMatrix)

Embed "dataBits" using "getMaskPattern". On success, modify the matrix and return true. For debugging purposes, it skips masking process if "getMaskPattern" is -1. See 8.7 of JISX0510:2004 (p.38) for how to embed data bits.

public static void embedDataBits(BitArray dataBits, int maskPattern, ByteMatrix matrix)

Parameters

dataBits BitArray

The data bits.

maskPattern int

The mask pattern.

matrix ByteMatrix

The matrix.

embedTypeInfo(ErrorCorrectionLevel, int, ByteMatrix)

Embed type information. On success, modify the matrix.

public static void embedTypeInfo(ErrorCorrectionLevel ecLevel, int maskPattern, ByteMatrix matrix)

Parameters

ecLevel ErrorCorrectionLevel

The ec level.

maskPattern int

The mask pattern.

matrix ByteMatrix

The matrix.

findMSBSet(int)

Return the position of the most significant bit set (to one) in the "value". The most significant bit is position 32. If there is no bit set, return 0. Examples:

  • findMSBSet(0) => 0
  • findMSBSet(1) => 1
  • findMSBSet(255) => 8
public static int findMSBSet(int value_Renamed)

Parameters

value_Renamed int

The value_ renamed.

Returns

int

makeTypeInfoBits(ErrorCorrectionLevel, int, BitArray)

Make bit vector of type information. On success, store the result in "bits" and return true. Encode error correction level and mask pattern. See 8.9 of JISX0510:2004 (p.45) for details.

public static void makeTypeInfoBits(ErrorCorrectionLevel ecLevel, int maskPattern, BitArray bits)

Parameters

ecLevel ErrorCorrectionLevel

The ec level.

maskPattern int

The mask pattern.

bits BitArray

The bits.

makeVersionInfoBits(Version, BitArray)

Make bit vector of version information. On success, store the result in "bits" and return true. See 8.10 of JISX0510:2004 (p.45) for details.

public static void makeVersionInfoBits(Version version, BitArray bits)

Parameters

version Version

The version.

bits BitArray

The bits.

maybeEmbedVersionInfo(Version, ByteMatrix)

Embed version information if need be. On success, modify the matrix and return true. See 8.10 of JISX0510:2004 (p.47) for how to embed version information.

public static void maybeEmbedVersionInfo(Version version, ByteMatrix matrix)

Parameters

version Version

The version.

matrix ByteMatrix

The matrix.