Class Decoder
- java.lang.Object
-
- com.google.zxing.datamatrix.decoder.Decoder
-
public final class Decoder extends java.lang.ObjectThe main class which implements Data Matrix Code decoding -- as opposed to locating and extracting the Data Matrix Code from an image.
-
-
Field Summary
Fields Modifier and Type Field Description private ReedSolomonDecoderrsDecoder
-
Constructor Summary
Constructors Constructor Description Decoder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private intcorrectErrors(byte[] codewordBytes, int numDataCodewords)Given data and error-correction codewords received, possibly corrupted by errors, attempts to correct the errors in-place using Reed-Solomon error correction.DecoderResultdecode(boolean[][] image)Convenience method that can decode a Data Matrix Code represented as a 2D array of booleans.DecoderResultdecode(BitMatrix bits)Decodes a Data Matrix Code represented as aBitMatrix.
-
-
-
Field Detail
-
rsDecoder
private final ReedSolomonDecoder rsDecoder
-
-
Method Detail
-
decode
public DecoderResult decode(boolean[][] image) throws FormatException, ChecksumException
Convenience method that can decode a Data Matrix Code represented as a 2D array of booleans. "true" is taken to mean a black module.
- Parameters:
image- booleans representing white/black Data Matrix Code modules- Returns:
- text and bytes encoded within the Data Matrix Code
- Throws:
FormatException- if the Data Matrix Code cannot be decodedChecksumException- if error correction fails
-
decode
public DecoderResult decode(BitMatrix bits) throws FormatException, ChecksumException
Decodes a Data Matrix Code represented as a
BitMatrix. A 1 or "true" is taken to mean a black module.- Parameters:
bits- booleans representing white/black Data Matrix Code modules- Returns:
- text and bytes encoded within the Data Matrix Code
- Throws:
FormatException- if the Data Matrix Code cannot be decodedChecksumException- if error correction fails
-
correctErrors
private int correctErrors(byte[] codewordBytes, int numDataCodewords) throws ChecksumExceptionGiven data and error-correction codewords received, possibly corrupted by errors, attempts to correct the errors in-place using Reed-Solomon error correction.
- Parameters:
codewordBytes- data and error correction codewordsnumDataCodewords- number of codewords that are data bytes- Returns:
- the number of errors corrected
- Throws:
ChecksumException- if error correction fails
-
-