192 lines
6.9 KiB
Java
192 lines
6.9 KiB
Java
package o;
|
|
|
|
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
|
|
import com.google.zxing.WriterException;
|
|
import java.lang.reflect.Array;
|
|
import java.nio.charset.Charset;
|
|
import java.util.Map;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public final class WkX implements InterfaceC16283mxN {
|
|
@Override // o.InterfaceC16283mxN
|
|
public final C8902dZc d(String str, PTS pts, int i, int i2, Map<EnumC14826gQH, ?> map) throws WriterException {
|
|
boolean z;
|
|
int i3;
|
|
boolean z2;
|
|
int i4;
|
|
int i5;
|
|
int i6;
|
|
int d;
|
|
if (pts != PTS.PDF_417) {
|
|
throw new IllegalArgumentException("Can only encode PDF_417, but got ".concat(String.valueOf(pts)));
|
|
}
|
|
LDn lDn = new LDn();
|
|
if (map != null) {
|
|
if (map.containsKey(EnumC14826gQH.PDF417_COMPACT)) {
|
|
lDn.b = Boolean.parseBoolean(map.get(EnumC14826gQH.PDF417_COMPACT).toString());
|
|
}
|
|
if (map.containsKey(EnumC14826gQH.PDF417_COMPACTION)) {
|
|
lDn.c = pvP.valueOf(map.get(EnumC14826gQH.PDF417_COMPACTION).toString());
|
|
}
|
|
if (map.containsKey(EnumC14826gQH.PDF417_DIMENSIONS)) {
|
|
PVL pvl = (PVL) map.get(EnumC14826gQH.PDF417_DIMENSIONS);
|
|
int i7 = pvl.e;
|
|
int i8 = pvl.c;
|
|
int i9 = pvl.b;
|
|
int i10 = pvl.a;
|
|
lDn.i = 0;
|
|
lDn.g = 0;
|
|
lDn.j = 0;
|
|
lDn.f = 0;
|
|
}
|
|
i3 = map.containsKey(EnumC14826gQH.MARGIN) ? Integer.parseInt(map.get(EnumC14826gQH.MARGIN).toString()) : 30;
|
|
r4 = map.containsKey(EnumC14826gQH.ERROR_CORRECTION) ? Integer.parseInt(map.get(EnumC14826gQH.ERROR_CORRECTION).toString()) : 2;
|
|
if (map.containsKey(EnumC14826gQH.CHARACTER_SET)) {
|
|
lDn.a = Charset.forName(map.get(EnumC14826gQH.CHARACTER_SET).toString());
|
|
}
|
|
z = map.containsKey(EnumC14826gQH.PDF417_AUTO_ECI) && Boolean.parseBoolean(map.get(EnumC14826gQH.PDF417_AUTO_ECI).toString());
|
|
} else {
|
|
z = false;
|
|
i3 = 30;
|
|
}
|
|
int e = SFe.e(r4);
|
|
String c = ypC.c(str, lDn.c, lDn.a, z);
|
|
int length = c.length();
|
|
float f = BitmapDescriptorFactory.HUE_RED;
|
|
int[] iArr = null;
|
|
for (int i11 = lDn.g; i11 <= lDn.i && (d = LDn.d(length, e, i11)) >= lDn.f; i11++) {
|
|
if (d <= lDn.j) {
|
|
float f2 = (((i11 * 17) + 69) * 0.357f) / (d * 2.0f);
|
|
if (iArr == null || Math.abs(f2 - 3.0f) <= Math.abs(f - 3.0f)) {
|
|
f = f2;
|
|
iArr = new int[]{i11, d};
|
|
}
|
|
}
|
|
}
|
|
if (iArr == null) {
|
|
int d2 = LDn.d(length, e, lDn.g);
|
|
int i12 = lDn.f;
|
|
if (d2 < i12) {
|
|
iArr = new int[]{lDn.g, i12};
|
|
}
|
|
}
|
|
if (iArr != null) {
|
|
int i13 = iArr[0];
|
|
int i14 = iArr[1];
|
|
int c2 = LDn.c(length, e, i13, i14);
|
|
if (e + length + 1 > 929) {
|
|
StringBuilder sb = new StringBuilder("Encoded message contains too many code words, message too big (");
|
|
sb.append(str.length());
|
|
sb.append(" bytes)");
|
|
throw new WriterException(sb.toString());
|
|
}
|
|
int i15 = length + c2 + 1;
|
|
StringBuilder sb2 = new StringBuilder(i15);
|
|
sb2.append((char) i15);
|
|
sb2.append(c);
|
|
for (int i16 = 0; i16 < c2; i16++) {
|
|
sb2.append((char) 900);
|
|
}
|
|
String obj = sb2.toString();
|
|
String b = SFe.b(obj, r4);
|
|
lDn.e = new SSA(i14, i13);
|
|
StringBuilder sb3 = new StringBuilder();
|
|
sb3.append(obj);
|
|
sb3.append(b);
|
|
String obj2 = sb3.toString();
|
|
SSA ssa = lDn.e;
|
|
int i17 = 0;
|
|
int i18 = 0;
|
|
while (i17 < i14) {
|
|
int i19 = i17 % 3;
|
|
ssa.b++;
|
|
LDn.e(130728, 17, ssa.e[ssa.b]);
|
|
if (i19 == 0) {
|
|
i5 = (i17 / 3) * 30;
|
|
i4 = ((i14 - 1) / 3) + i5;
|
|
i6 = i13 - 1;
|
|
} else if (i19 == 1) {
|
|
i5 = (i17 / 3) * 30;
|
|
int i20 = i14 - 1;
|
|
i4 = (r4 * 3) + i5 + (i20 % 3);
|
|
i6 = i20 / 3;
|
|
} else {
|
|
int i21 = (i17 / 3) * 30;
|
|
i4 = (i13 - 1) + i21;
|
|
i5 = i21 + (r4 * 3);
|
|
i6 = (i14 - 1) % 3;
|
|
}
|
|
int i22 = r4;
|
|
LDn.e(LDn.d[i19][i4], 17, ssa.e[ssa.b]);
|
|
int i23 = 0;
|
|
while (i23 < i13) {
|
|
LDn.e(LDn.d[i19][obj2.charAt(i18)], 17, ssa.e[ssa.b]);
|
|
i18++;
|
|
i23++;
|
|
obj2 = obj2;
|
|
}
|
|
String str2 = obj2;
|
|
if (lDn.b) {
|
|
LDn.e(260649, 1, ssa.e[ssa.b]);
|
|
} else {
|
|
LDn.e(LDn.d[i19][i5 + i6], 17, ssa.e[ssa.b]);
|
|
LDn.e(260649, 18, ssa.e[ssa.b]);
|
|
}
|
|
i17++;
|
|
obj2 = str2;
|
|
r4 = i22;
|
|
}
|
|
byte[][] d3 = lDn.e.d(1, 4);
|
|
if ((i2 > i) != (d3[0].length < d3.length)) {
|
|
d3 = b(d3);
|
|
z2 = true;
|
|
} else {
|
|
z2 = false;
|
|
}
|
|
int min = Math.min(i / d3[0].length, i2 / d3.length);
|
|
if (min > 1) {
|
|
byte[][] d4 = lDn.e.d(min, min << 2);
|
|
if (z2) {
|
|
d4 = b(d4);
|
|
}
|
|
return a(d4, i3);
|
|
}
|
|
return a(d3, i3);
|
|
}
|
|
throw new WriterException("Unable to fit message in columns");
|
|
}
|
|
|
|
private static C8902dZc a(byte[][] bArr, int i) {
|
|
int i2 = i << 1;
|
|
C8902dZc c8902dZc = new C8902dZc(bArr[0].length + i2, bArr.length + i2);
|
|
int length = c8902dZc.a.length;
|
|
for (int i3 = 0; i3 < length; i3++) {
|
|
c8902dZc.a[i3] = 0;
|
|
}
|
|
int i4 = (c8902dZc.c - i) - 1;
|
|
int i5 = 0;
|
|
while (i5 < bArr.length) {
|
|
byte[] bArr2 = bArr[i5];
|
|
for (int i6 = 0; i6 < bArr[0].length; i6++) {
|
|
if (bArr2[i6] == 1) {
|
|
c8902dZc.a(i6 + i, i4);
|
|
}
|
|
}
|
|
i5++;
|
|
i4--;
|
|
}
|
|
return c8902dZc;
|
|
}
|
|
|
|
private static byte[][] b(byte[][] bArr) {
|
|
byte[][] bArr2 = (byte[][]) Array.newInstance((Class<?>) Byte.TYPE, bArr[0].length, bArr.length);
|
|
for (int i = 0; i < bArr.length; i++) {
|
|
int length = bArr.length;
|
|
for (int i2 = 0; i2 < bArr[0].length; i2++) {
|
|
bArr2[i2][(length - i) - 1] = bArr[i][i2];
|
|
}
|
|
}
|
|
return bArr2;
|
|
}
|
|
}
|