102 lines
3.5 KiB
Java
102 lines
3.5 KiB
Java
package com.google.zxing.datamatrix;
|
|
|
|
import com.google.zxing.BarcodeFormat;
|
|
import com.google.zxing.BinaryBitmap;
|
|
import com.google.zxing.ChecksumException;
|
|
import com.google.zxing.DecodeHintType;
|
|
import com.google.zxing.FormatException;
|
|
import com.google.zxing.NotFoundException;
|
|
import com.google.zxing.Reader;
|
|
import com.google.zxing.Result;
|
|
import com.google.zxing.ResultMetadataType;
|
|
import com.google.zxing.ResultPoint;
|
|
import com.google.zxing.common.BitMatrix;
|
|
import com.google.zxing.common.DecoderResult;
|
|
import com.google.zxing.common.DetectorResult;
|
|
import com.google.zxing.datamatrix.decoder.Decoder;
|
|
import com.google.zxing.datamatrix.detector.Detector;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class DataMatrixReader implements Reader {
|
|
private static final ResultPoint[] b = new ResultPoint[0];
|
|
private final Decoder a = new Decoder();
|
|
|
|
@Override // com.google.zxing.Reader
|
|
public Result a(BinaryBitmap binaryBitmap, Map<DecodeHintType, ?> map) throws NotFoundException, ChecksumException, FormatException {
|
|
ResultPoint[] b2;
|
|
DecoderResult decoderResult;
|
|
if (map == null || !map.containsKey(DecodeHintType.PURE_BARCODE)) {
|
|
DetectorResult a = new Detector(binaryBitmap.a()).a();
|
|
DecoderResult a2 = this.a.a(a.a());
|
|
b2 = a.b();
|
|
decoderResult = a2;
|
|
} else {
|
|
decoderResult = this.a.a(a(binaryBitmap.a()));
|
|
b2 = b;
|
|
}
|
|
Result result = new Result(decoderResult.h(), decoderResult.e(), b2, BarcodeFormat.DATA_MATRIX);
|
|
List<byte[]> a3 = decoderResult.a();
|
|
if (a3 != null) {
|
|
result.a(ResultMetadataType.BYTE_SEGMENTS, a3);
|
|
}
|
|
String b3 = decoderResult.b();
|
|
if (b3 != null) {
|
|
result.a(ResultMetadataType.ERROR_CORRECTION_LEVEL, b3);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
@Override // com.google.zxing.Reader
|
|
public void reset() {
|
|
}
|
|
|
|
private static BitMatrix a(BitMatrix bitMatrix) throws NotFoundException {
|
|
int[] j = bitMatrix.j();
|
|
int[] b2 = bitMatrix.b();
|
|
if (j != null && b2 != null) {
|
|
int a = a(j, bitMatrix);
|
|
int i = j[1];
|
|
int i2 = b2[1];
|
|
int i3 = j[0];
|
|
int i4 = ((b2[0] - i3) + 1) / a;
|
|
int i5 = ((i2 - i) + 1) / a;
|
|
if (i4 > 0 && i5 > 0) {
|
|
int i6 = a / 2;
|
|
int i7 = i + i6;
|
|
int i8 = i3 + i6;
|
|
BitMatrix bitMatrix2 = new BitMatrix(i4, i5);
|
|
for (int i9 = 0; i9 < i5; i9++) {
|
|
int i10 = (i9 * a) + i7;
|
|
for (int i11 = 0; i11 < i4; i11++) {
|
|
if (bitMatrix.b((i11 * a) + i8, i10)) {
|
|
bitMatrix2.c(i11, i9);
|
|
}
|
|
}
|
|
}
|
|
return bitMatrix2;
|
|
}
|
|
throw NotFoundException.getNotFoundInstance();
|
|
}
|
|
throw NotFoundException.getNotFoundInstance();
|
|
}
|
|
|
|
private static int a(int[] iArr, BitMatrix bitMatrix) throws NotFoundException {
|
|
int k = bitMatrix.k();
|
|
int i = iArr[0];
|
|
int i2 = iArr[1];
|
|
while (i < k && bitMatrix.b(i, i2)) {
|
|
i++;
|
|
}
|
|
if (i != k) {
|
|
int i3 = i - iArr[0];
|
|
if (i3 != 0) {
|
|
return i3;
|
|
}
|
|
throw NotFoundException.getNotFoundInstance();
|
|
}
|
|
throw NotFoundException.getNotFoundInstance();
|
|
}
|
|
}
|