62 lines
2.2 KiB
Java
62 lines
2.2 KiB
Java
package com.google.zxing.maxicode;
|
|
|
|
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.maxicode.decoder.Decoder;
|
|
import java.util.Map;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class MaxiCodeReader 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 {
|
|
if (map == null || !map.containsKey(DecodeHintType.PURE_BARCODE)) {
|
|
throw NotFoundException.getNotFoundInstance();
|
|
}
|
|
DecoderResult a = this.a.a(a(binaryBitmap.a()), map);
|
|
Result result = new Result(a.h(), a.e(), b, BarcodeFormat.MAXICODE);
|
|
String b2 = a.b();
|
|
if (b2 != null) {
|
|
result.a(ResultMetadataType.ERROR_CORRECTION_LEVEL, b2);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
@Override // com.google.zxing.Reader
|
|
public void reset() {
|
|
}
|
|
|
|
private static BitMatrix a(BitMatrix bitMatrix) throws NotFoundException {
|
|
int[] h = bitMatrix.h();
|
|
if (h != null) {
|
|
int i = h[0];
|
|
int i2 = h[1];
|
|
int i3 = h[2];
|
|
int i4 = h[3];
|
|
BitMatrix bitMatrix2 = new BitMatrix(30, 33);
|
|
for (int i5 = 0; i5 < 33; i5++) {
|
|
int i6 = (((i5 * i4) + (i4 / 2)) / 33) + i2;
|
|
for (int i7 = 0; i7 < 30; i7++) {
|
|
if (bitMatrix.b(((((i7 * i3) + (i3 / 2)) + (((i5 & 1) * i3) / 2)) / 30) + i, i6)) {
|
|
bitMatrix2.c(i7, i5);
|
|
}
|
|
}
|
|
}
|
|
return bitMatrix2;
|
|
}
|
|
throw NotFoundException.getNotFoundInstance();
|
|
}
|
|
}
|