jimu-decompiled/sources/com/google/zxing/oned/OneDimensionalCodeWriter.java
2025-05-13 19:24:51 +02:00

75 lines
2.1 KiB
Java

package com.google.zxing.oned;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.Writer;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
import java.util.Map;
/* loaded from: classes.dex */
public abstract class OneDimensionalCodeWriter implements Writer {
public int a() {
return 10;
}
@Override // com.google.zxing.Writer
public BitMatrix a(String str, BarcodeFormat barcodeFormat, int i, int i2, Map<EncodeHintType, ?> map) throws WriterException {
if (str.isEmpty()) {
throw new IllegalArgumentException("Found empty contents");
}
if (i < 0 || i2 < 0) {
throw new IllegalArgumentException("Negative size is not allowed. Input: " + i + 'x' + i2);
}
int a = a();
if (map != null && map.containsKey(EncodeHintType.MARGIN)) {
a = Integer.parseInt(map.get(EncodeHintType.MARGIN).toString());
}
return a(a(str), i, i2, a);
}
public abstract boolean[] a(String str);
private static BitMatrix a(boolean[] zArr, int i, int i2, int i3) {
int length = zArr.length;
int i4 = i3 + length;
int max = Math.max(i, i4);
int max2 = Math.max(1, i2);
int i5 = max / i4;
BitMatrix bitMatrix = new BitMatrix(max, max2);
int i6 = (max - (length * i5)) / 2;
int i7 = 0;
while (i7 < length) {
if (zArr[i7]) {
bitMatrix.a(i6, 0, i5, max2);
}
i7++;
i6 += i5;
}
return bitMatrix;
}
protected static int a(boolean[] zArr, int i, int[] iArr, boolean z) {
int length = iArr.length;
int i2 = i;
boolean z2 = z;
int i3 = 0;
int i4 = 0;
while (i3 < length) {
int i5 = iArr[i3];
int i6 = i2;
int i7 = 0;
while (i7 < i5) {
zArr[i6] = z2;
i7++;
i6++;
}
i4 += i5;
z2 = !z2;
i3++;
i2 = i6;
}
return i4;
}
}